ASP.Net身份注销身份、ASP、Net

由网友(始于心动,终于白首)分享简介:如何注销一个用户登录与ASP.Net识别系统?How to logout an user logged in with the ASP.Net Identity system?我想:Authentication.SignOut();但是,如果我用这个,然后调用的API标记 [授权] (将令牌作为报头)它仍然返回我...

如何注销一个用户登录与ASP.Net识别系统?

How to logout an user logged in with the ASP.Net Identity system?

我想:

Authentication.SignOut();

但是,如果我用这个,然后调用的API标记 [授权] (将令牌作为报头)它仍然返回我的数据(而不是未授权)。

But if I use this and then call an API marked with [Authorize] (adding the token as an header) It still returns me the data (instead of Unauthorized).

推荐答案

您需要调用 SignOut 的AuthenticationManager 您可以从 OWIN上下文中获取

You need to call SignOut on the AuthenticationManager which you can get from the OWIN context.

var AutheticationManager = HttpContext.GetOwinContext().Authentication;
AuthenticationManager.SignOut();
阅读全文

相关推荐

最新文章