Asp.net mvc 未被IE删除的OWIN Cookies

Asp.net mvc 未被IE删除的OWIN Cookies,asp.net-mvc,authentication,cookies,owin,Asp.net Mvc,Authentication,Cookies,Owin,我遇到一个问题,其中以下代码似乎无法按预期工作: AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); 当执行上述代码行时,我希望以下属性为false AuthenticationManager.User.Identity.IsAuthenticated 但事实并非如此,它仍然是正确的(仅适用于IE,我正在使用IE 11) 我通过以下属性公开我的Owin上下文: public IAuthent

我遇到一个问题,其中以下代码似乎无法按预期工作:

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
当执行上述代码行时,我希望以下属性为false

AuthenticationManager.User.Identity.IsAuthenticated
但事实并非如此,它仍然是正确的(仅适用于IE,我正在使用IE 11)

我通过以下属性公开我的Owin上下文:

public IAuthenticationManager AuthenticationManager
{ 
    get 
    { 
        return HttpContext.Current.GetOwinContext().Authentication; 
    } 
}
我还尝试使用以下代码手动删除身份验证cookie:

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

var appCookie = HttpContext.Current.Request.Cookies[".AspNet.AuthCookie"];

if (appCookie != null)
{
    appCookie = new HttpCookie(".AspNet.AuthCookie");
    appCookie.Expires = DateTime.Now.AddYears(-1);
    HttpContext.Current.Response.Cookies.Add(appCookie);                
}
同样,它在IE中不起作用。它在Chrome中起作用

仅供参考,我正在Startup.Auth.cs中手动设置cookie的名称

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    ExpireTimeSpan = TimeSpan.FromMinutes(Config.AuthenticationCookieTimeOutMinutes),
    CookieHttpOnly = true, 
    CookieName = ".AspNet.AuthCookie",
    LoginPath = new PathString("/Account/Login"),
    CookieSecure = CookieSecureOption.SameAsRequest                
});
在线上有很多关于Signout()方法不能正常工作的信息,但大多数解决方案都是手动删除cookie,我对此并不满意。为什么这在IE 11中不起作用

更新

因此,我无法解决IE中Cookie的问题,但是通过覆盖authorizedRequest属性的HandleUnauthorizedRequest虚拟来解决此问题,以查看用户是否已通过身份验证,然后再次检查会话中持有的当前用户

protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext)
{
    UserAccount currentUser = (UserAccount)filterContext.HttpContext.Session[SessionStrings.CurrentUser];

    if (filterContext.HttpContext.Request.IsAuthenticated && currentUser != null)
    { 
        ...
    }
    else
    {
        base.HandleUnauthorizedRequest(filterContext);
    }
}

有完全相同的问题。您最终找到解决方案了吗?有问题的更新提供。最终不得不重写授权属性的HandleUnauthorizedRequest,这有点像黑客,但这是我能找到的唯一解决办法