相关疑难解决方法(0)

是否有应用于Web API ApiController方法的默认动词?

我一直在看这篇文章的代码(在https://github.com/patelsan/WebAPIAuthentication中):http://www.codeproject.com/Articles/630986/Cross-Platform-Authentication-With-ASP- NET-Web-API.

它非常好,似乎工作正常.很少有文章解释这种令牌认证,但这是我见过的最好的.请注意,我是这项技术的新手,还有很多需要学习的地方.

所以,我注意到UsersController有这样的代码:

public class UsersController : ApiController
{
    public Status Authenticate(User user)
    {
        . . .
    }
}
Run Code Online (Sandbox Code Playgroud)

Authenticate方法不是以已知的HTTP动词开头,例如Get或Post,并且没有与此方法关联的[HttpGet]或[HttpPost]属性,那么控制器如何知道哪个动词与此方法相关联?只需查看代码,我怎么知道我需要使用哪个动词?如果没有匹配的话,是否存在"默认"动词这样的事情?

顺便说一句,如果你想知道,唯一有效的动词是POST.我很想知道为什么会这样.

asp.net asp.net-web-api asp.net-web-api-routing

13
推荐指数
2
解决办法
7091
查看次数