基本上,当用户在浏览器中单击“返回”(或使用按键控制)时,我正在构建的该站点上的所有页面都无法访问,并且如果尝试返回历史记录,则该页面应该过期。
我放入 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()
这将清除缓存并在用户注销时不允许返回任何页面,但在用户登录时不会执行此工作。
我看到人们建议使用 javascript 方法的帖子,通过调用
History.Forward(1)
在页面上。但我不想这样做,因为它需要启用 javascript 才能工作(用户可以禁用)。
感谢任何建议。