ASP.NET Web服务从不触发Application_Error
个事件,并且不能像在ASP.NET应用程序中那样由ELMAH全局处理异常.但是我们可以使用ELMAH"手动"记录异常:
public int WebServiceMethod() {
try {
...
}
catch (Exception ex) {
Elmah.ErrorLog.GetDefault(
HttpContext.Current).Log(new Elmah.Error(ex, HttpContext.Current));
}
}