繁体   English   中英

注销功能不适用于ASP.NET身份

[英]Logout functionality not working with ASP.NET identity

我正在尝试退出应用程序,但是身份验证cookie并未被删除。 下面是我的实现

//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中却没有。 我花了几天的时间尝试解决它,然后决定更新基本控制器中的某些跟踪代码。 重新编译后,问题消失了。

我不想追溯我的步骤以验证它是否是一种解决方案,但我想知道项目是否需要进行全新的编译,并修改其他引用其实现相同目的身份的代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM