If I create a controller action and do not decorate it with AcceptVerbs
, HttpPost
or HttpGet
. What is the default behaviour?
D
it depends on the name of the action. If the action starts with "Get*" then it will default to only accept GET requests. If it starts with "Put*" then it will default to only accept PUT requests. Same with POST.
If it doesn't start with any known verb then it will default to only accept POST.
Here are the results of my testing:
public class BlahController : ApiController
{
// only allows GET
public string GetSomething() { return "GetSomething blah"; }
// only allows PUT
public string PutSomething() { return "PutSomething blah"; }
// only allows POST
public string PostSomething() { return "PostSomething blah"; }
// only allows POST
public string Fleabag() { return "Fleabag blah"; }
}
It's accessible via any verb.