当连接意外关闭时,ASP.NET 页面生命周期是否会完整运行?
尽管远程连接意外关闭导致流数据无法发送给客户端,Asp.net 是否仍会运行其完整页面生命周期?它是一个带有默认值的空白 asp.net 页面。我担心 OnUnLoad 事件没有被执行。它真的会发生吗?
有人有这方面的详细信息吗?
Will Asp.net run its full page life cycle although the remote connection was closed unexpectedly to a state that stream data cannot be send the client? It is a blank asp.net page with default values. and I am concern about OnUnLoad event not being executed. Will it actually happen?
Anyone got any detail info on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您应该以不依赖于该事件执行的方式设计页面。
网络/网络是不可预测的,任何事情都可能发生,浏览器崩溃、错误、连接丢失或缓慢或工作正常,然后不再工作......
我相信,当您关闭浏览器时,网络请求将被处理,但因为你询问网络表单页面的生命周期,它以
Page_PreRender
结束,然后将数据发送到客户端,有很多变量和可能性,我认为总是想象整个生命周期更安全即使没有人使用/消费,也会被执行 回复。I think you should design your pages in a way that does not rely on that event execution.
The web/network is unpredictable, anything can always happen, browser crash, bug, connection is lost or slow or works and doesn't then works again...
I am convinced that when you close the browser the web request is disposed but since you ask about the web form page life cycle, it concludes with the
Page_PreRender
then the data is sent to the client, there are so many variables and possibilities that I think is safer to always imagine the whole life cycle will get executed even if there will be nobody to use/consume the response.这只是一个猜测,但我认为客户端断开连接会以某种方式引发 ThreadAbortException 。因此,接下来的任何事件都不会再发生。当然,您可以尝试捕获异常,然后释放资源。
This is just a guess, but I think that client disconnection somehow raises a
ThreadAbortException
. Hence, any of the next events will not occur any more. You can, of course, try to catch the exception and then free up your resources.