简体   繁体   中英

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

I'm working on asp.net MVC5 with VS2013, and testing my webapp. And I found that, when I login my website with (remember me?) checked . I'll sometimes can not logoff correctly. Then I find in debug tools,that each time when I logoff, It will request a new cookie with Authentication. How should I do with this situation?

This is the code for LogOff.

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

This is the problem where I think:

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

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

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM