Possible MapServiceRoute bug?

Topics: Web Api
Jun 30, 2011 at 8:53 PM

When using Web Api with MVC3 I've found a problem with MapServiceRoute when you supply your own ServiceHostFactory. Using this is fine (as in the quick start sample):

RouteTable.Routes.MapServiceRoute<ContactResource>("contact");

However, I was playing about trying to supply my own ServiceHostFactory but started having problems - even when supplying the same one the Web Api itself uses by default:

RouteTable.Routes.MapServiceRoute<ContactResource, HttpConfigurableServiceHostFactory>("contact");

I find that 7 route constraints get placed into the route. When calling the service I then get an error related to the first constraint:

The constraint entry 'Length' on the route with URL 'contact/{*pathInfo}' must have a string value or be of a type which implements IRouteConstraint.

I know there are 3 extension methods and if I copy and paste the source from the extension method that is used I have no problems. I've double-checked things and I still can't work out what is happening.