Is it possible to override the IHttpRouteData

Topics: ASP.NET Web API
Jun 25, 2012 at 9:51 PM

I am creating a tree of routes and using a custom IHttpControllerSelector to select the appropriate controller (The syntax for creating the routes is similiar to https://github.com/darrelmiller/ApiRouter, however I implemented it using an IHttpControllerSelector rather than a Delegating Handler).

In my IHttpControllerSelector, I am replacing the HttpRouteData that was attached to the request, but it never makes it to the controller.  I did some looking and it seems that my RouteData instance was still tied to the Request, however the one on the HttpControllerContext was the original one.

Looking at the latest source, i see that the HttpRouteData is extracted from the request before the IHttpControllerSelector is called which explains why the original HttpRouteData is passed into the ControllerContext.

Is there a nice way to get my custom IHttpRouteData into the HttpControllerContext, or am I going about this the wrong way?