posted 12/22/2008 by Vivek Thakur
The "Back" browser button (or for that matter any other browser button) cannot be actually disabled by a web application as the security context will not allow this (think of what nasty things could happen if web applications can remove buttons from client browsers!)
What we can do is to somehow make sure that browser does not cache the web pages (which will cause the"Back" "Forward" buttons to grey out), and this can be easily done by expiring the Response. The code for this has slightly changed in ASP.NET 2.0 (there is a new HttpCachePolicy class) :
/* * Code disables caching by browser. Hence hitting the back browser button * causes the Page_Load event to fire again. */ Response.Cache.SetCacheability(HttpCacheability.NoCache);Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time
In ASP.NET 1.x the code was: Response.CacheControl = "no-cache"; Response.AddHeader("Pragma","no-cache"); Response.Expires = -1;
This will make the browser go to the server everytime the back button is clicked (for that particular page) and prevent any caching of the pages.
try this in ur logout button/link..its works for me...as it refreshs the page after the Session.abondon(); so its not possible to go bak to ur previous page without logging again.. protected void logOut_b_Click(object sender, ImageClickEventArgs e) { Session.Abandon(); Response.AddHeader("Refresh",Convert.ToString((Session.Timeout * 0))); if(Session["Name"].ToString()=="") { Server.Transfer("login.aspx"); } }
protected void logOut_b_Click(object sender, ImageClickEventArgs e) { Session.Abandon(); Response.AddHeader("Refresh",Convert.ToString((Session.Timeout * 0))); if(Session["Name"].ToString()=="") { Server.Transfer("login.aspx"); } }
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18