Dis-allow MVC actions to be fired only by GET or POST method

Posted by vishalneeraj-24503 under ASP.NET MVC category on | Points: 40 | Views : 1704
We can use the MVC action with the HttpGet or HttpPost attribute to dis-allow the type of HTTP calls.

For example:-
We can see in the below example,the ViewEmployee action can only be invoked by HttpGet.If we try to make HTTP POST on ViewEmployee action,then we will get an error.
public ViewResult ViewEmployee(int emp_id)
Employee_Master emp = Employees[emp_id];
return View("ViewEmployee",emp );

Comments or Responses

Login to post response