1

I have a logout in my mastrpage.page_load in which I disable the cache like so:

Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";

Response.Redirect("Login.aspx");

The logout functionalitly works fine if the page gets refreshed and you are logged out, you go to the login page. But if you logout and hit back button, you can still go to the previous page.

How do I fix this from happening?

cdub
  • 24,555
  • 57
  • 174
  • 303

1 Answers1

1

You can try this in Page_Load event.

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Page.Response.Cache.SetNoStore();

For mor information you can read this. Setting the Cacheability of a Page

Amit
  • 21,570
  • 27
  • 74
  • 94
  • thanks i had no cache and it still wasn't working but i'll check out the notes in the link – cdub May 10 '12 at 21:57
  • @chris: This is also a good read http://stackoverflow.com/questions/10525172/what-is-different-between-httpcacheability-nocache-and-response-cachecontrol – Amit May 10 '12 at 22:07
  • @chris: If you are satisfy with the answer, please don't forget to accept it as answer. It will help future reader. – Amit May 10 '12 at 22:11
  • nice that worked finally! it was working in IE with the other code, but not in FF but both are working now – cdub May 10 '12 at 22:11