Click here to Skip to main content
15,921,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a project in which I have cleared the cache by the following lines :
C#
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";

I am using these lines in the master page itself so that none of the page is cached and when I press back button after log out that page does not show.But it happens even during a sessin that pressing the back button or the forward button gives the message "web page expired" which looks very weired .What should be the way of doing this that even the pages are not cached and also the back buttons do not show the weired messge to the users.
Posted
Updated 1-Mar-13 1:19am
v2
Comments
bbirajdar 1-Mar-13 8:25am    
Try that code on your logout page
Sandeep Mewara 1-Mar-13 10:05am    
Bingo.
Devashish2013 4-Mar-13 2:01am    
I already tried putting that code in logout , but then too it will cache all the pages which the user had navigated just before logout.Hence after logout if he clicks back button then it will show the pages which should not be shown if the user has not logged in.
bbirajdar 4-Mar-13 2:13am    
Then disable the back button using javascript history.go(-1);

1 solution

Put the following code snippet at page load event

Response.AppendHeader("Cache-Control", "no-store");
 
Share this answer
 
v2

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