ASP.Net身份注销 [英] ASP.Net Identity Logout

查看:109
本文介绍了ASP.Net身份注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何注销一个用户登录与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();

这篇关于ASP.Net身份注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆