Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top