为什么Global.asax中的Application_Error方法不捕获由ASMX服务抛出的异常? [英] Why global.asax Application_Error method does not catch exceptions thrown by ASMX service?

查看:432
本文介绍了为什么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.

杰夫阿特伍德有一个帖子(和<一个href=\"http://blog.codinghorror.com/throwing-better-net-exceptions-with-soap-and-http/\">follow-up)这个几年前,有以下思路:

Jeff Atwood had a post (and follow-up) about this a few years ago, with the following ideas:


  • 将一个try-catch块围绕每个Web服务方法

  • 使用门面设计模式,包括在try-catch中的父对象

  • 编写自定义SOAP扩展或HTTP模块

我关心的只有一个是第一位的,即使它似乎是一个大量的工作。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆