Disable browser back button

Susanthampy
Posted by Susanthampy under ASP.NET category on | Points: 40 | Views : 4142
Actually we can't disable the browser back button. In this code we are clearing the browser cache.

Add the following code to the Page_Load event of ASP.NET web page
// Disable the Cache
Response.Buffer= true;
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

// Check for your SessionID
if(Session["SessionId"] == null)
{
Response.Redirect ("Home.aspx");
}

Comments or Responses

Posted by: Lakn2 on: 6/2/2011 Level:Starter | Status: [Member] | Points: 10
hi good one in another approach we can do
<script language="text/javascript">
function back()
{
windows.history.forward(1);
}
</script>
<body onload="back()">
....
Posted by: Jayeshl on: 6/3/2011 Level:Starter | Status: [Member] | Points: 10
hi friends
you are right at your functionality requirements
but as per my view following code is also work at their

Response.Cache.SetCacheability(HttpCacheability.Private);

Response.Cache.SetCacheability(HttpCacheability.NoCache);


try it
it will also disabled back button.

thanks
Jayesh L
http://www.sqlassistant.blogspot.com

Login to post response