开发者

Can a WCF ServiceRoute Route Prefix contain a path value?

开发者 https://www.devze.com 2023-01-06 01:44 出处:网络
Currently I use this: RouteTable.Routes.Add(new ServiceRoute(\"API\", new WebServiceHostFactory(),typeof(MySite.Web.MyServiceV1)));

Currently I use this:

RouteTable.Routes.Add(new ServiceRoute("API", new WebServiceHostFactory(),typeof(MySite.Web.MyServiceV1)));

To make this url point to the MyServiceV1.SVC MySite.com/API


I want to use a Prefix which contains a / in it but it doesn't seem to work.

RouteTable.Routes.Add(new ServiceRoute("API/V2", new WebServiceHostFactory(),typeof(MySite.Web.MyServiceV2)));

Is t开发者_如何学编程here a better way to represent this instead of having to do "APIV2" ? I am using .Net 4.0


I totally forgot that the order you register routes mattered. This works:

RouteTable.Routes.Add(new ServiceRoute("API/V2/", new WebServiceHostFactory(),typeof(MySite.Web.MyServiceV2)))

RouteTable.Routes.Add(new ServiceRoute("API/", new WebServiceHostFactory(),typeof(MySite.Web.MyServiceV1)));
0

精彩评论

暂无评论...
验证码 换一张
取 消