are these things the same?
[HttpPost/HttpGet] vs. [AcceptVerbs(HttpVerbs.Post开发者_开发知识库/Get)]
if not where is a difference?
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.
Yes they are the same but with the newer versions you can only make an action accept requests from one verb. Using [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get | HttpVerbs.Delete)]
you can accept 2 or more. Also you can use [AcceptVerbs]
to accept other verbs that are not part of the HttpVerbs
enum - eg. [AcceptVerbs("Trace")]
.
I'm not sure why you would ever need to use this functionality but you are able to should you wish.
精彩评论