0

我有一个具有母版页和多个普通页面的 asp.net 网站。母版页上有一个菜单栏,使用户能够选择普通页面。我在其中一个普通页面的 Page_Load 事件中有代码。问题是,这个事件似乎只触发一次——用户第一次导航到页面。如果用户导航到另一个页面然后再次返回,则不会触发该事件。谁能告诉我我做错了什么?

4

2 回答 2

1

If user user Back Button of browser browser will use cached version of your pages if your pages are normal and no specific setting applied to them. these codes cause if user use Back button nothing show to him/her:

Response.Cache.SetExpires(DateTime.Now.AddDays(-1)) ;
Response.Cache.SetValidUntilExpires(false) ;
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches) ;
Response.Cache.SetCacheability(HttpCacheability.NoCache) ;
Response.Cache.SetNoStore();

Or for prvent user to go back use this code:

<body onLoad="if(history.length>0)history.go(+1)"> 
于 2012-04-15T19:54:40.223 回答
0

看来问题是由浏览器缓存页面引起的,谢谢你指出我正确的方向。

这个问题不仅出现在使用后退按钮时,所以我担心这并不能解决问题。

我的解决方案是用服务器端 asp.net 按钮控件替换我用于菜单的简单 html 超链接。当后面的代码执行 response.redirect 时,似乎每次都会执行目标页面的 page_load 事件。

于 2012-04-16T20:57:12.103 回答