Can a WCF ServiceRoute Route Prefix contain a path value?

亡梦爱人 提交于 2019-12-01 07:32:05

问题


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 there a better way to represent this instead of having to do "APIV2" ? I am using .Net 4.0


回答1:


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)));


来源:https://stackoverflow.com/questions/3186858/can-a-wcf-serviceroute-route-prefix-contain-a-path-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!