为什么不Page_Load中使用ASP.NET从另一个页面回来后射击 - ERGO史诗尴尬:) [英] Why is Page_Load not firing after coming back from another page using ASP.NET - ergo epic embarrassment :)

查看:92
本文介绍了为什么不Page_Load中使用ASP.NET从另一个页面回来后射击 - ERGO史诗尴尬:)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我在同一个ASP.NET C#网页两页。

Let's say I have two pages on the same ASP.NET C# WebSite.


  • Page1.aspx的做事在Page_Load事件

  • 我导航使用菜单Page2.aspx

  • Page2.aspx做一些事情然后点击的Response.Redirect 返回Page1.aspx的

  • Page1.aspx的不能因为它永远不会触发做的事情在Page_Load事件这个时候。

  • Page1.aspx does things in the Page_Load event
  • I navigate to Page2.aspx using the menu
  • Page2.aspx does some things then Response.Redirect back to Page1.aspx
  • Page1.aspx cannot do things in Page_Load event this time because it never fires.

我想声明的方式关闭缓存,在我使用重定向如此endResponse ......似乎没有什么有所作为尝试。

I tried to turn off cache declaratively, tried using true for endResponse in my redirect... nothing seems to make a difference.

没关系大家!我是个白痴!
使用Visual Studio开发本地主机重定向被重定向到活页! :)

推荐答案

之所以执行不影响页面周期,Load事件的页面的总是的当执行网页火灾。

The reason for the page executing doesn't affect the page cycle, the Load event always fires when the page is executed.

所以,如果在Page_Load有时不跑,这是因为页面被缓存并没有在服务器上执行。该页面可以在浏览器中使用服务器端的页面缓存缓存中,在路由器沿途某处,或者在服务器上。

So, if the Page_Load doesn't run sometimes, it's because the page is cached and doesn't execute on the server. The page can be cached in the browser, in a router somewhere along the way, or on the server using server side page caching.

如果您还没有启用服务器端页面缓存的页面,它的缓存在浏览器或网络。您可以使用缓存设置来尝试elliminate这样的:

If you haven't enabled server side page caching for the page, it's cached in the browser or in the network. You can use cache settings to try to elliminate this:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

这将保持页面在正常情况下被缓存。 (也请检查您的浏览器是不是在离线模式下,那么它会在缓存中使用任何东西,无论它是可缓存的设置。)

This will keep the page from being cached in normal circumstances. (Check also that your browser isn't in offline mode, then it will use anything in the cache regardless of it's cacheability settings.)

这篇关于为什么不Page_Load中使用ASP.NET从另一个页面回来后射击 - ERGO史诗尴尬:)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆