为什么WCF服务引发异常时不会触发Application_Error? [英] Why Application_Error not be fired when a WCF service thrown exception?
问题描述
我有一个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屋!