How to Host WCF REST Service and WCF Data Service in the same global.asax

依然范特西╮ 提交于 2019-12-04 13:26:54

It turns out this was exceedingly simple and I completely overlooked the obvious.

It appears when you are hosting multiple service routes you cannot have a default/empty route prefix on any of the routes as you can with a single route. Note this was what I had in my question above for the UserService route.

Thus providing a route prefix for both service routes allows both services to be hosted within the same global.asax.

Providing code for completeness...

protected override void RegisterRoutes(System.Web.Routing.RouteCollection routeTable)
{
    routeTable.Add(new ServiceRoute("Rest", new WebServiceHostFactory(),
                   typeof(UserService)));
    routeTable.Add(new ServiceRoute("OData", new DataServiceHostFactory(),
                   typeof(UserDataService)));
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!