【发布时间】:2022-01-21 11:08:00
【问题描述】:
在我的 ASP.Net Web API 项目中,我向控制器添加了 [Authorize] 属性。因此,当我调用该方法时,它返回错误为
"Message": "Authorization has been denied for this request."
如何连同我的请求一起发送Authorize 标头。
控制器
[Authorize]
[HttpPost]
public HttpResponseMessage Settings(SettingModel data)
{
--Do i need to check authorize headers manually here?
--code goes here
}
这里叫
http://localhost/sample/api/Settings
Headers
{
Content-Type: application/json
Authorization: What value need to be send here?
}
【问题讨论】:
-
当您说基于令牌的授权时,您是指来自 Identity Server 的 JWT,可能是版本 4,还是您在使用其他东西?
标签: asp.net-mvc-4 asp.net-web-api authorization