最新最好的方式来处理通过浏览器历史记录中的ASP.NET页面加载? [英] Whats the best way to deal with pages loaded via browser history in asp .net?
问题描述
我有一个应用程序,这是非常数据库和用户密集。用户是在导航,浏览器历史记录按钮非常热衷。
I have an app which is very database and user intensive. The users are very keen on the browser history buttons for navigation.
有没有办法,我绝对可以保证,如果用户挑选出来的东西自己浏览器历史记录页面将重新加载的方法吗?
Is there a way that I can absolutely guarantee that the page will reload if a user picks something out of their browser history?
我经常看到的是,网页的副本将从浏览器缓存中显示,而不是重新加载。
What I regularly see is that a copy of the page will be shown from the browsers cache, rather than being reloaded.
我试过:
this.Response.Cache.SetNoStore()
this.Response.Cache.SetNoServerCaching()
this.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache)
和
this.Response.Cache.SetExpires(DateTime.Now.AddSeconds ( -1 ) );
这些都不似乎帮助,有时浏览器将装载反正老缓存版本。
None of these seems to help, sometimes the browser will load the old cached version anyway.
推荐答案
您需要两个语句prevent缓存:
You need two statements to prevent caching:
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //对于IE
Response.Cache.SetNoStore(); //对于Firefox
有关详细见:
<一个href=\"http://blog.httpwatch.com/2008/10/15/two-important-differences-between-firefox-and-ie-caching/\" rel=\"nofollow\">http://blog.httpwatch.com/2008/10/15/two-important-differences-between-firefox-and-ie-caching/
此外,请确保您始终遵循重定向信息,这样后退按钮正常工作:
Also, make sure that you always follow a POST with a redirect so that the back button works correctly:
<一个href=\"http://blog.httpwatch.com/2007/10/03/60-of-web-users-can%E2%80%99t-be-wrong-%E2%80%93-don%E2%80%99t-break-the-back-button/\" rel=\"nofollow\">http://blog.httpwatch.com/2007/10/03/60-of-web-users-can%E2%80%99t-be-wrong-%E2%80%93-don%E2%80%99t-break-the-back-button/
这篇关于最新最好的方式来处理通过浏览器历史记录中的ASP.NET页面加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!