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?

Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top