ASP.NET MVC: HttpPost action filter
In ASP.NET MVC controller, HttpPost action method selector attribute let us restrict action method so that specified action method is only accessible via HTTP POST verb or request. HttpPost is inherited from ActionMethodSelectorAttribute which is used to validate action method selection based on controller context.
Attribute Usage: Only method
Sample Code:
[HttpPost]
public ActionResult About()
{
return Json(Model);
}
Generally we should mark action method with HttpPost whenever we are returning Json result from action method in other word whenever action method is consumed by only AJAX request at that time we should mark it with HttpPost attribute. However this is not the only scenario. If we try to access action method with other than POST verb then it will throw HTTP 404 not found error.
Check out ASP.NET MVC: Action filter series post to read about other available action filters.
You can follow me on twitter for latest link and update on ASP.NET & MVC.