Is there a default verb applied to a Web API ApiController method?

前端 未结 2 1382
一生所求
一生所求 2020-11-30 10:12

I\'ve been looking at the code (in https://github.com/patelsan/WebAPIAuthentication) from this article: http://www.codeproject.com/Articles/630986/Cross-Platform-Authenticat

2条回答
  •  庸人自扰
    2020-11-30 10:45

    In this special case, the default Http Verb is POST. In other scenarios, the default verb depends on the name of the action and other factors. Below is the algorithm quoted from asp.net:

    HTTP Methods. The framework only chooses actions that match the HTTP method of the request, determined as follows:

    1. You can specify the HTTP method with an attribute: AcceptVerbs, HttpDelete, HttpGet, HttpHead, HttpOptions, HttpPatch, HttpPost, or HttpPut.

    2. Otherwise, if the name of the action (controller method) starts with "Get", "Post", "Put", "Delete", "Head", "Options", or "Patch", then by convention the action supports that HTTP method.

    3. If none of the above, the method supports POST.

    http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection

提交回复
热议问题