簡體   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