ASP.NET MVC: Exiting a View Once Called

I have a logout action that goes into logout mode. User information is still displayed after pressing the logout button. I am completely logged out after moving to another URL, why is this so? How can I handle this? Client side redirection?

Act:

    public ViewResult LogOut()
    {
        FormsAuthentication.SignOut();
        return View();
    }
+3
source share
3 answers

I am using javascript event to redirect page.

0
source

Try to get rid of the authentication token:

FormsAuthentication.SignOut();
Context.Response.Cookies.Item(FormsAuthentication.FormsCookieName).Expires = Date.Now;
return RedirectToAction("LogOut");

Also, make sure the page is not cached:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore();
+2
source

Session.Abandon();

+1

Source: https://habr.com/ru/post/1779517/


All Articles