Hello I am developing a solution in MVC in first time so I am facing a big issue, When I logout from my application(mvc razor web application) it displays login page, but if i press browser back button it displays last screen, i don't want this, i want if i press back button it still display same login page. here is my code for logout
public ActionResult Logout()
{
Session.Clear();
Session.Abandon();
Session.RemoveAll();
FormsAuthentication.SignOut();
this.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
this.Response.Cache.SetCacheability(HttpCacheability.NoCache);
this.Response.Cache.SetNoStore();
return RedirectToAction("Login");
}
I had this problem a while ago, disabling the cache for the entire application solved my problem, just add these line to the
Global.asax.cs
fileHope this helps.
Easiest way for a MVC 5 Application is:
Above each of the Controller Methods you don't want to Cache. Or if you are using .Core the following works:
Have a nice day!
You need to add the cache
META
Tag for all the last page you visitedSo add this for all the pages, by making a CustomAttribute like
[NoCache]
and decorateOr try it with javascript on the page like