Equivalent of ServiceRoute?

Topics: ASP.NET Web API
May 12, 2012 at 10:28 PM

Hi all,

With the new WebAPI, how can I register a route in the same way I used to do with ServiceRoute? Is it at all possible?

I'd like to control the activation process, register an instance of a controller against a static route, and so on.

Are those things possible?

My apologies if the above are already documented. I tried to search through the documentation but couldn't find anything.



May 13, 2012 at 1:44 PM

ASP.NET Web API has a concept of dependency injection which is currently global and not route-dependent.

The idea is that you implement IDependencyResolver and set it against the configuration:   


May 15, 2012 at 12:07 AM

ASP.NET Web API supports ASP.NET Routing including route paramters, default values and route constraints. Use the MapHttpRoute extension method to register a route:


name: "DefaultApi",

routeTemplate: "api/{controller}/{id}",

defaults: new { id = RouteParameter.Optional }


Daniel Roth