[英]ASP.NET Identity - AuthenticationManager.SignOut not working
我試圖在JWT令牌過期時注銷我的用戶。 但是由於某些原因,我退出后,ClaimsPrincipal仍然存在。
例如:Request.IsAuthenticated即使在我大聲說出來后也始終為true。
我正在注銷所有可用的身份驗證類型。 (ApplicationCookie,ExternalCookie,Auth0)。
我不確定這里可能缺少什么。
internal static void SignOut()
{
var authenticationManager = HttpContext.Current.Request.GetOwinContext().Authentication;
if (authenticationManager == null) return;
var appTypes = authenticationManager.GetAuthenticationTypes().Select(at => at.AuthenticationType).ToArray();
authenticationManager.SignOut(appTypes);
var httpResponse = HttpContext.Current.Response;
var httpRequest = HttpContext.Current.Request;
httpResponse.Redirect(
string.Format("https://{0}/logout?returnTo={1}",
ConfigurationManager.AppSettings["auth0Domain"],
httpRequest.Url));
}
感謝您提出的建議/想法,這些指導/想法可能會指導我解決該問題。
謝謝你的時間。 我從“ ActionFilter”中調用Signout(),即使調用了Signout,action方法仍繼續執行。 我通過退出會話解決了該問題,然后進行了設置
filterContext.Result = new RedirectResult('logouturl)
在過濾器中。 這樣,它停止了執行Action方法並正確注銷了用戶
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.