[HttpPost] and [Acceptverbs (httpverbs.post)] Difference

Source: Internet
Author: User

1. Common denominator:[HttpPost] and [Acceptverbs (Httpverbs.post)] are the only data that accepts Post requests.

2. Different points:
In MVC, if you want an action to respond to a POST request or respond to a GET request, what should we do?
First [HttpPost] and [HttpGet] are not simultaneously present on an action
But [Acceptverbs (Httpverbs.get | Httpverbs.post)] can

Correct wording:
[Acceptverbs (Httpverbs.get | Httpverbs.post)] or [Acceptverbs ("Post", "GET", "Options")]
Public ActionResult Index ()
{
........................
}

Error wording:
[HttpPost] [HttpGet]
Public ActionResult Index ()
{
........................
}

!!! Note:

The

http specification defines 8 possible request methods:
get                   retrieves a simple request to identify a resource in the URI
head                 As with the Get method, the server returns only the status line and header, Does not return the request document
post                The   server accepts requests that are written to data in the client output stream
put             The       server holds the request data as a request for the new content of the specified URI
delete              Server Delete Request for named resource in URI
options            Request for Request method information supported by the server
trace              Web server feedback HTTP request and its header request
connect         a method that has been documented but not currently implemented, reserved for tunneling

[HttpPost] and [Acceptverbs (httpverbs.post)] differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.