为什么WCF服务引发异常时不会触发Application_Error? [英] Why Application_Error not be fired when a WCF service thrown exception?

查看:68
本文介绍了为什么WCF服务引发异常时不会触发Application_Error?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个biz层,就像这样:

I have a biz layer just like this:


public SchoolInfo GetSchoolInfoByID(int id) 
{
        return SchoolDAO.GetSchoolInfoByID(id);
}

推荐答案

据我所知,Application_Error事件永远不会触发Web服务,甚至不支持Asmx Web服务.要为WCF Web服务实施错误处理,您可以实施 IErrorHandler 接口.

To my knowledge, the Application_Error event never fires for a web service, not even for asmx web services. To implement error handling for a WCF web service, you can implement the IErrorHandler interface.

以下是一些示例:

- http://blogs.msdn.com/b/carlosfigueira/archive/2011/06/07/wcf-extensibility-ierrorhandler.aspx

- http://blogs.msdn.com/b/carlosfigueira/archive/2011/06/07/wcf-extensibility-ierrorhandler.aspx

- http://codeidol.com/csharp/wcf/Faults/Error-Handling-Extensions/

- http://codeidol.com/csharp/wcf/Faults/Error-Handling-Extensions/

- http://www.haveyougotwoods.ca/2009/06/24/creating-a-global-error-handler-in-wcf

- http://www.haveyougotwoods.ca/2009/06/24/creating-a-global-error-handler-in-wcf

 


这篇关于为什么WCF服务引发异常时不会触发Application_Error?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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