我有一个 C# WebService 应用程序,我想在其中捕获应用程序抛出的所有未处理的异常。
我怎样才能做到这一点?
由于某种原因,Web 服务不会触发 Application_Error 事件(请参阅其他问题)。杰夫·阿特伍德先生本人也发表了一些建议在编码恐怖博客上.
他写:
* Put a try..catch around every WebService method. These methods tend to be wrappers around other classes, so this isn't quite as bad as it sounds, but it's still not good.
* use a Facade design pattern to derive all objects from parent objects that.. basically do a try..catch on the .Execute method. Uh, thanks but no thanks.
* Write a custom SOAP Extension or HttpModule. This sounds reasonable but.. hard. If it's such a cool, important extension or HttpModule, wouldn't someone have written it already?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)