【问题标题】:Cannot log off while using asp.net mvc5 identity, cookies refreshed on posting使用 asp.net mvc5 身份时无法注销,发布时刷新 cookie
【发布时间】:2015-06-04 07:12:33
【问题描述】:

我正在使用 VS2013 开发 asp.net MVC5,并测试我的 webapp。 我发现,当我使用(还记得我吗?)登录我的网站时。我有时无法正确注销。 然后我在调试工具中发现,每次我注销时,它都会请求一个带有身份验证的新 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());
}

【问题讨论】:

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


    【解决方案1】:

    除非您使用以下内容,否则它似乎并不总是正确清除 cookie:

    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
    

    【讨论】:

      猜你喜欢
      • 2019-04-04
      • 2014-04-29
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-08
      相关资源
      最近更新 更多