webapi中的授权 [英] Authorization in webapi
本文介绍了webapi中的授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用jwt身份验证创建了一个webapi。我可以在未经授权的情况下获得响应,当我向控制器添加了authorize属性时,它给了我未经授权的正确信息。但是当我发送授权标题时,它给出了CORS错误并请求不起作用。我需要发送任何属性吗?
I have created a webapi with jwt authentication. I am able to get response without authorization, when i have added authorize attribute to controller, its giving me unauthorized which is correct. But when i sent authorization header its giving CORS error and request not working. Is there any attribute i need to send?
this.httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer '+ this.readCookie()
})
};
return this.http.get("http://localhost:50507/api/employee").toPromise();
谢谢
我有什么尝试过:
尝试使用$ .ajax获得相同的错误。
Thanks
What I have tried:
Tried with $.ajax getting same error.
推荐答案
.ajax得到同样的错误。
.ajax getting same error.
这篇关于webapi中的授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文