为什么global.asax Application_Error方法不能捕获ASMX服务抛出的异常? [英] Why global.asax Application_Error method does not catch exceptions thrown by ASMX service?
本文介绍了为什么global.asax Application_Error方法不能捕获ASMX服务抛出的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以及如何解决这个问题。我想记录每个抛出的异常以进行维护。
And how to fix it. I'd like to log every thrown exception for maintenance purpose.
推荐答案
这是.Net中的一个已知问题 - Application_Error从不触发用于Web服务。不知道是否有理由设计,但是它不起作用。
This is a known issue in .Net - Application_Error never fires for a web service. Not sure if there's any reason it would be by design, but it just doesn't work.
Jeff Atwood有一个 post (和后续)关于这个几年前,有以下想法:
Jeff Atwood had a post (and follow-up) about this a few years ago, with the following ideas:
- 在每个Web服务方法周围放置一个try-catch块
- 使用外观设计模式,并将try-catch包含在父对象中
- 编写自定义的SOAP扩展或HTTPModule
我唯一关心的是第一个,即使它似乎是很多工作。
The only one I care for is the first one, even though it seems like a lot of work.
这篇关于为什么global.asax Application_Error方法不能捕获ASMX服务抛出的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文