【发布时间】:2014-03-21 22:20:45
【问题描述】:
我的应用程序设置为必须使用 Web API 中的授权属性“授权”除登录之外的所有请求。例如
[Authorize]
[HttpGet, Route("api/account/profile")]
public ApplicationUser Profile()
{
return userModel;
}
只有登录不需要授权,因为那是你获得令牌的地方;)
[AllowAnonymous]
[HttpPost, Route("api/account/login")]
public async Task<IHttpActionResult> Login(LoginViewModel model)
{
....
}
不必将[Authorize] 属性添加到我的所有路线,有没有办法全局设置它?
【问题讨论】:
标签: c# .net asp.net-web-api asp.net-web-api2