Search code examples
asp.net-mvcasp.net-mvc-5logoutasp.net-identity-2

ASP.Net MVC 5 w/identity 2.2.0 Log off not working


I am using a the basic login on a test ASP.Net MVC 5 site (for an internet site).

The login works fine but when I try to logout it doesn't happen. The logout link does call the following controller action:

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

But the user stays logged in. How do I ensure that the user actually gets logged out?


Solution

  • I had this problem before, change:

    AuthenticationManager.SignOut();
    

    To:

    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
    

    Assuming that you are using ApplicationCookie to store your login information.