使用 asp.net mvc5 身份时无法注销,cookie 在发布时刷新

Cannot log off while using asp.net mvc5 identity, cookies refreshed on posting

我正在使用 VS2013 开发 asp.net MVC5,并测试我的网络应用程序。 我发现,当我登录我的网站时(还记得我吗?) checked 。我有时无法正确注销。 然后我在调试工具中发现,每次我注销时,它都会请求一个带有身份验证的新 cookie。 这种情况应该怎么办?

这是注销代码。

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
    AuthenticationManager.SignOut();
    return RedirectToAction("Index", "Home");
}

这是我认为的问题所在:

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
    filters.Add(new System.Web.Mvc.AuthorizeAttribute());
    filters.Add(new HandleErrorAttribute());
}

似乎它并不总能正确清除 cookie,除非您使用以下方法:

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);