Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I logout from my website and press browser back button, then the last page is displayed again, but I want to redirect it to login.aspx page. How can I do it?
Posted
Updated 14-Mar-10 13:36pm
v3

1 solution

This happens because of Cache.

Clear the cache such that browser has no history (this will make back/forward button in browser grayed out disabled.)
The code for clearing cache can be put up in code behind as follows:

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();


You can add something similar in form aspx if you want to place it there:

<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">


Just feels like I answered you this last week, hope it's not a re-post and this solves the problem for you.
 
Share this answer
 
v3

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