我有一个在Visual Studio 2010中创建的ASP.NET项目。所以开始项目时,我得到了通用的“MY ASP.NET APPLICATION”页面。我已经删除了所有这些通用内容,并且正在根据用户的需求构建应用程序。Asp.Net在浏览器上点击后退按钮时强制Page_Load
在我的default.aspx页面上,我有一个datagrid
包裹在UpdatePanel
中。当用户从datagrid
中选择一行时,我将导航到新页面。一切工作正常,但如果用户点击浏览器中的后退按钮,它就好像是从旧缓存版本加载页面,因为它再次显示通用“MY ASP.NET应用程序”页面。
我已经研究了一段时间,一切都表明,如果你告诉Response
不使用缓存,它会强制Page_Load
,如果用户点击后退按钮。但是,这样做并不适合我。如果我点击刷新按钮或键入F5,那么我的页面将成功重新加载。我使用IE9和这里是我在我的母版页的Page_Load
曾尝试:
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Expires = -1441;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
Response.AppendHeader("pragma", "no-cache");
Response.CacheControl = "No-cache";
Response.AddHeader("cache-control", "no-store, no-cache, must-revalidate");
而且,我试着在母版页的脚本插入这样的:
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>
也许这在你的文档的开始会有帮助吗? http://stackoverflow.com/a/11341116/109749 – jcolebrand 2012-07-11 20:42:42