ASP.Net 页面方法异常没有冒泡?

发布于 2024-07-21 03:02:53 字数 185 浏览 9 评论 0原文

我不明白为什么静态 ASP.Net Page 方法的异常没有冒泡到要在 global.asax 文件中处理的 Application_Error 事件。 我并不是真的期待任何错误,但我希望安全并了解它们是否确实发生,并且不想将每个静态方法包装在 try...catch 中。

有谁知道如何捕获这些异常,或者至少知道为什么它们不冒泡?

I can't figure out why the exception from a static ASP.Net Page method isn't bubbling up to the Application_Error event to be handled in the global.asax file. I'm not really expecting any errors, but I would like to be safe and know about them if they do happen to occur and would rather not wrap every static method in a try...catch.

Does anyone know how to catch these exceptions or at least why they aren't bubbling?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

厌倦 2024-07-28 03:02:53

如果未在较低层中处理异常,则异常将冒泡到 Application_Error 中的错误处理程序。 如果您已经有一个 TRY/CATCH 块,您认为异常正在发生,那么它将在此时被捕获。

请发布您的静态方法的代码和您的Application_Error。 它将更容易为您提供准确的答案,而不是笼统的答案。

Exceptions bubble to the error handler in Application_Error if they are not being handled in the lower layers. If you already have a TRY/CATCH block where you think the exception is occurring, it will be trapped at that point.

Please post the code of your static method and your Application_Error. It will make it easier to provide you with an accurate answer instead of a generalized one.

半窗疏影 2024-07-28 03:02:53

如果在 Visual Studio 中进行开发,您应该调试代码,然后单步执行源代码以查找异常,并在冒泡到 Application_Error 方法之前查看捕获异常的内容。

If developing in Visual Studio, you should debug your code and then step through the source to find the exception and see what is catching it before bubbling up to your Application_Error method.

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