ASP.Net:导航回来时到期页面 [英] ASP.Net: Expiring a page when navigating back
问题描述
基本上我构建时,用户点击后退(或与关键控制),在浏览器中,如果一个人试图导航回到历史页面应该到期。不能访问这个网站的所有网页p>
我投入的Global.asax ::的Application_BeginRequest
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
Response.Cache.SetValidUntilExpires(假)
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
Response.Cache.SetNoStore()
这将清除缓存并禁止回去当用户登录任何网页,但在用户登录并没有做的工作。
我看到的帖子,人们使用JavaScript的方式,建议通过调用
History.Forward(1)
在页面上。但我不喜欢这样做,因为这将需要启用javascript工作(其中用户可以禁用)。
鸭preciate任何建议。
您可以始终如一地做到这一点的唯一方法是,如果你使用的是 HTTPS
。如果没有,你没有办法强制浏览器不使用缓存的页面。还有你提到关于黑客,但他们都没有充分证明。如果它真的很重要,使用 HTTPS
,因为每个请求将强制重新加载。
Basically all pages on this site I am building cannot be accessed when the user clicks on "Back" (or with key control) in the browser, and the page should expire if one is trying to navigate back in history.
I put into Global.asax::Application_BeginRequest
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
Response.Cache.SetValidUntilExpires(False)
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
Response.Cache.SetNoStore()
This would clear out the cache and disallow going back to any pages when the user is logged out, but doesn't do the job while the user is logged in.
I saw posts where people suggested using a javascript approach, by calling
History.Forward(1)
on the page. But I wouldn't like to do this, as it will require javascript enabled to work (which user can disable).
Appreciate any suggestions.
The only way you can consistently do this is if you are using https
. If not you have no way to enforce the browser to not use a cached page. There are the hacks you mentioned about but they are not full proof. If it is really important, use https
because each request will force a reload.
这篇关于ASP.Net:导航回来时到期页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!