注销功能不适用于ASP.NET标识

时间:2015-02-01 13:15:45

标签: c# asp.net-mvc 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

            });

1 个答案:

答案 0 :(得分:0)

如果它对其他人有用。将项目从MVC2升级到MVC5后,我在Chrome中遇到了这个问题,但没有IE。我花了几天时间试图解决它,然后决定更新我在基础控制器中的一些跟踪代码。重新编译后问题就消失了。

我不想回溯我的步骤以验证这是一个解决方案,但我想知道该项目是否需要一个干净的重新编译,并通过修改引用该标识的其他代码,它实现了同样的事情

相关问题