【问题标题】:Logout functionality not working with ASP.NET identity注销功能不适用于 ASP.NET 标识
【发布时间】:2015-03-31 12:49:52
【问题描述】:

我正在尝试退出应用程序,但身份验证 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

            });

【问题讨论】:

标签: c# asp.net-mvc asp.net-identity


【解决方案1】:

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

我不想回溯我的步骤来验证这是一个解决方案,但我想知道该项目是否需要彻底重新编译并修改引用它实现相同目标的其他代码。

【讨论】:

    猜你喜欢
    • 2023-03-02
    • 1970-01-01
    • 1970-01-01
    • 2010-10-17
    • 1970-01-01
    • 2016-07-09
    • 2011-04-19
    • 1970-01-01
    相关资源
    最近更新 更多