Click here to Skip to main content
15,887,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hiiiiii..

m working on web appln....hav login form..wen i navigate to 2nd page and press back btn of browser i'll get redirected to login page..
nw wen i press d forwrd btn of d browser i shud not b navigated to d 2nd page instead i need 2 show login page itself..



so how to do this.......plz:confused:
Posted

1 solution

Generally, browser back and forward buttons use the cache copy. So while going forward and coming back no server code is re-run. Thus it would be difficult for you to show login page if one comes back after logging in.

Alternative would be to not allow pages to be cached. This would disable/gray out the back forward button of browser. Thus, user wont be able to do back/forward.

Here you can use:
This can be easily done by expiring the Response. The code for this in ASP.NET 2.0:
C#
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900