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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top