注销功能不适用于ASP.NET身份 [英] Logout functionality not working with ASP.NET identity
问题描述
我正在尝试退出应用程序,但是身份验证cookie并未被删除.下面是我的实现
I am trying to sign out of the application, but the authentication cookie is not getting deleted. Below is my implementation
//Log in action
var identity = new ClaimsIdentity(new[] {
new Claim(ClaimTypes.Name, loginModel.UserName),
},
DefaultAuthenticationTypes.ApplicationCookie,
ClaimTypes.Name,
ClaimTypes.Role);
Authentication.SignIn(new AuthenticationProperties
{
IsPersistent = loginModel.RememberMe
}, identity);
//logout action
IAuthenticationManager Authentication
{
get { return HttpContext.GetOwinContext().Authentication; }
}
Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
//startup
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
//AuthenticationMode = AuthenticationMode.Active
});
推荐答案
以防其他人使用.将项目从MVC2升级到MVC5后,我在Chrome中遇到了这个问题,但在IE中却没有.我花了几天的时间来解决它,然后决定更新基本控制器中的某些跟踪代码.重新编译后,问题消失了.
In case it's useful to someone else. I had this problem in Chrome but not IE after upgrading a project from MVC2 to MVC5. I spent days trying to solve it and then decided to update some of the tracking code I had in my base Controller. After recompiling the problem went away.
我不想追溯我的步骤以验证它是否是一种解决方案,但是我想知道项目是否需要进行干净的重新编译,并修改其他引用其实现相同功能的代码.
I don't want to retrace my steps to verify this as a solution, but I'm wondering if the project needed a clean recompilation and by modifying other code that referenced the identity that it achieved the same thing.
这篇关于注销功能不适用于ASP.NET身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!