What is the difference between [AcceptVerbs(HttpVerbs.Post)] and [HttpPost]?

asp.net Mvcasp.net Mvc-2Http PostHttp Get

asp.net Mvc Problem Overview


I can decorate an action either with the [AcceptVerbs(HttpVerbs.Post)]/[AcceptVerbs(HttpVerbs.Get)]

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(string title)
{
    // Do Something...
}

or with the [HttpPost]/[HttpGet] attributes

[HttpPost]
public ActionResult Create(string title)
{
    // Do Something...
}

Are they different?

asp.net Mvc Solutions


Solution 1 - asp.net Mvc

[HttpPost] is shorthand for [AcceptVerbs(HttpVerbs.Post)]. The only difference is that you can't use [HttpGet, HttpPost] (and similar) together on the same action. If you want an action to respond to both GETs and POSTs, you must use [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)].

Solution 2 - asp.net Mvc

Nothing. One is just shorthand for the other.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLorenzoView Question on Stackoverflow
Solution 1 - asp.net MvcRudresha ParameshappaView Answer on Stackoverflow
Solution 2 - asp.net MvcMatthew ManelaView Answer on Stackoverflow