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

John S picture John S · Feb 21, 2015 · Viewed 11.2k times · Source

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?

Answer

Ashley Medway picture Ashley Medway · Feb 21, 2015

I had this problem before, change:

AuthenticationManager.SignOut();

To:

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

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