我有一个WCF/REST Web服务,我试图添加一个全局异常处理程序。我正在寻找类似于标准.NET网站中的Application_Error事件的东西。将全局错误处理添加到WCF REST服务
我发现大量的信息有关使用IErrorHandler和IServiceBehavior接口一样怎么在这里详细介绍:http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.ierrorhandler.aspx#Y1479
这似乎是我所需要的,但我发现每一个例子假设该服务在网络中定义。配置。我没有这样做 - 我使用RouteTables,在Global.asax配置,就像这样:
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
// Edit the base address of Service1 by replacing the "Service1" string below
RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHost2Factory(), typeof(myService)));
}
因此,鉴于这种情况,我该如何配置我的自定义IErrorHandler和IServiceBehavior接口?我甚至在正确的轨道上,因为我使用的是一个RouteTable,而不是通过web.config配置它?我很新WCF ....
这是正确的答案。请给这个人所有的要点! :) –