我该如何处理由ASMX服务抛出的异常? [英] How do I handle exceptions thrown by asmx services?

查看:245
本文介绍了我该如何处理由ASMX服务抛出的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.NET ASMX服务偶尔会抛出异常。然而,Global.asax中的Application_Error方法似乎并没有抓住他们。问题是,如何配置全局错误处理程序来捕捉和记录这些例外?

ASP.NET ASMX service occasionally throws exceptions. However, global.asax Application_Error method do not seem to catch them. The question is, how to configure global error handler to catch and log these exceptions?

推荐答案

基本问题(当然这不是一个问题)与ASMX Web服务是服务层后面的任何异常被抛出SOAP异常客户端。您需要捕获SOAP异常,然后寻找内部异常那里。

Basic problem (well it is not a problem) with ASMX web service is that any exception behind the service layer is thrown as SOAP exception to client. You need to catch SOAP exception and then look for inner exception there.

有一个更好的清洁方法是您实现您的应用程序SOAP处理程序。通过这个和客户端结束序列化SOAP异常反序列化。这样,您将有超过异常流量的完全控制,而不是.NET框架。

A better and clean approach is you implement SOAP handler in your application. Serialize the SOAP exception through this and on client end deserialize it. This way you will have complete control over exception flow, rather than .net framework.

心连心

这篇关于我该如何处理由ASMX服务抛出的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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