satheesh babu

satheesh babu

  • NA
  • 128
  • 312.5k

How to stop to display previous page when user press browser back button after log out?

Aug 25 2011 2:43 AM
Hi all,

For log in button i am checking the user id & password in data base and creating session object. In all pages page_load event I am checking the session & if the session exists then only i am displaying the page other wise i am redirecting to log in page.

Here I wrote below code for log out button. After log out click , i am redirecting to login.aspx page,its displaying login page , but if i press browser back button, its redirecting to my previous page and if I did any functionality then its checking the session object then its redirecting to log in page.

Please guide me how to stop my browser back button to don't display my previous page?

Session.Abandon();
Session.RemoveAll();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Session.Clear();
Session["User_Name"] = null;
Session["Subscriber_Id"] = null;
Session["ACCOUNT_ACCESS_TYPE"] = null;
Session["User_Id"] = null;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";
String script = "<script type=text/javascript\"" + ">window.history.forward(1)</script>";
Page.RegisterClientScriptBlock("backbutton", script);
Response.Redirect("~/SignIn.aspx");

Answers (1)