are these things the same?
[HttpPost/HttpGet] vs. [AcceptVerbs(HttpVerbs.Post/Get)]
if not where is a difference?
HTTPGet method creates a query string of the name-value pair whereas HTTPPost method passes the name and value pairs in the body of the HTTP request. 3. HTTPGet request has limited length and mostly it is limited to 255 characters long whereas HTTPPost request has no maximum limit.
The MVC framework includes HttpGet, HttpPost, HttpPut, HttpDelete, HttpOptions, and HttpPatch action verbs. You can apply one or more action verbs to an action method to handle different HTTP requests. If you don't apply any action verbs to an action method, then it will handle HttpGet request by default.
The [AcceptVerbs] attribute can be applied to action methods in a controller so that the appropriate overloaded method is invoked for a given request. ASP.NET MVC will automatically dispatch a request to the appropriate action method based on the HTTP verb.
HTTP Post. This verb is used while we have to create a new resource in the database. In HttpPost, data travels in the URL and body. To use HttpPost method, we use HttpPost attribute on the Action method.
Yes, absolutely the same. [HttpPost/HttpGet]
were introduced in ASP.NET MVC 2 to reduce the keystrokes we have to type :-) [AcceptVerbs(HttpVerbs.Post/Get)]
could still be used and behave the same although if you are writing new code I would recommend the first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With