Alexander Alexander - 24 days ago 10
C# Question

System.Web.Http.AcceptVerbs("GET") vs System.Web.Http.HttpGet

What exactly is the difference between

[System.Web.Http.AcceptVerbs("GET")]
public string[] SomeArray(string someString)
{


and

[System.Web.Http.HttpGet]
public string[] SomeArray(string someString)
{


and when would one use which of them, and when would one use both? I already found many examples using

[System.Web.Http.AcceptVerbs("GET")]
[System.Web.Http.HttpGet]
public string[] SomeArray(string someString)
{

Answer

Both of them are same. HttpPost/HttpGet attributes are a shortcut for the HttpVerbs.Post/HttpVerbs.Get since MVC 2.0.

See this :

  1. What is the difference between [AcceptVerbs(HttpVerbs.Post)] and [HttpPost]?
  2. asp.net mvc - [HttpPost/HttpGet] vs. [AcceptVerbs(HttpVerbs.Post/Get)]
Comments