Can a ServiceFoute WCF route prefix contain a path value?

I am currently using this:

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

To make this URL for MyServiceV1.SVC MySite.com/API


I want to use a prefix that contains a / in, but it does not work.

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

Is there a better way to introduce this instead of doing "APIV2"? I am using .Net 4.0

+3
source share
1 answer

I completely forgot that the order you registered was important. It 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)));
+10
source

Source: https://habr.com/ru/post/1753317/


All Articles