当连接意外关闭时,ASP.NET 页面生命周期是否会完整运行?

发布于 2024-12-05 02:06:32 字数 130 浏览 3 评论 0原文

尽管远程连接意外关闭导致流数据无法发送给客户端,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦归所梦 2024-12-12 02:06:32

我认为您应该以不依赖于该事件执行的方式设计页面。

网络/网络是不可预测的,任何事情都可能发生,浏览器崩溃、错误、连接丢失或缓慢或工作正常,然后不再工作......

我相信,当您关闭浏览器时,网络请求将被处理,但因为你询问网络表单页面的生命周期,它以 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.

待天淡蓝洁白时 2024-12-12 02:06:32

这只是一个猜测,但我认为客户端断开连接会以某种方式引发 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文