In my asp.net mvc project when a logged in user logs out and presses back button they are being able to back to the page and access data which needs you to be logged in.
I have already added this page to default page:
HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(false);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetValidUntilExpires(true);
This is my call to logout controller:
Welcome <b><%= Html.Encode(Page.User.Identity.Name)%></b>!
<%-- [ <%= Html.ActionLink("Logout", "Logout", "Home")%> ] --%>
<a href="#" onclick="Javascript:DisableHistory()"> Logout</a>
function DisableHistory() {
alert("testing123");
window.history.forward(1);
window.location = "http://localhost/test.web/Home.aspx/Logout";
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home");
}
THis happens only in firefox. How can I avoid it from caching that page.