Click here to Skip to main content
15,905,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,


In my ASP.NET application, i have an login page. After user login, he can go to whatever page he wants.

I'm using MASTER PAGE for each and every page except LoginPage.

My problem is after user Logout Click(which was in my MasterPage). I make him to redirect as...

Response.Redirect("~/login.aspx", true);

Its works fine...But while user clicks back button, my IE(default) browser take user to Previous page.

Hence i used an script like...

XML
<script type="text/javascript">
window.history.forward(1);
</script>



Its works good when i have it in an single(Content) page....but user may logout where ever he wants. So, i need to call this script on each Page.Hence i place it in my MASTERPAGE.

Unfortunately its not work .... So, am i need to place this script in each(all content) page???
Is this the Correct way??

Please direct me...
Posted
Updated 31-Jul-11 22:05pm
v2

1 solution

This isn't the right approach for obvious reasons. The correct way is to disable caching of your web page.
You can use these META tags inside your HEAD element.
HTML
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">

Or you can do it through your code-behind like this:
C#
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(false); 
 
Share this answer
 
Comments
J.Karthick 1-Aug-11 4:37am    
Thanks for your reply...

Is this applicable for MasterPage??
Where should i place this META tag??
[no name] 1-Aug-11 14:45pm    
As far as the browser is concerned, there is nothing called a master page. The ASP.NET runtime merges the master page and content page markup and produces the final HTML output that the browser sees. So it can be used it master pages. You should put all your META tags inside the HEAD tag.
J.Karthick 3-Aug-11 4:05am    
yaa....thanks for your valuable comments....

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