注销时清除浏览器缓存

注销时清除浏览器缓存

问题描述:

我有一个包含注销"按钮的页面,当用户单击注销"时,我执行Session.Abandon()并重定向到Login.aspx.这将清除我所有的会话变量.

但是,如果我再单击浏览器中的后退"按钮,则会再次显示单击注销"之前的最后一页.我相信这是由于缓存.当我在加载页面时包括以下代码时,将不会发生此问题.

I have a page that includes a ''Logout'' button, when the user clicks ''Logout'', I perform the Session.Abandon() and redirect to Login.aspx. This clears all my session variables fine.

But, if I then click the back button in the browser, the last page before clicking ''Logout'' is rendered again. I believe this is due to caching. As when I includes the following code when loading the page, this problem will not occur.

Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache");
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("Expires", "0");


但是,这段代码将禁用我页面的缓存.
我不想为我的页面禁用缓存,因为它会大大降低性能.我只想找到一种仅在用户单击注销"菜单项时清除缓存的方法.
有人可以帮忙吗?


However, this piece of code will disable the cache for my page.
I do not want to disable cache for my pages because it slows down the performance considerably. I just want to find a way to clear the cache ONLY when the user clicks the ''Logout'' menu item.
Can anyone help with this?

从Code Project中查看此提示
注销后浏览器后退按钮问题 [
Check out this Tips from Code Project
Browser back button issue after logout[^]