Question

I am writing a custom HttpControllerSelector to handle versioning in my API. I have looked at the SDammann.WebApi.Versioning library on github and when I ran it it appeared that the routing dictionary was populating on every request. Does the default one do this or is this a design flaw in the Sdammann library?

If I have a lot of controllers, will populating this dictionary on every request be a performance hit? Is there another way to do this?

Was it helpful?

Solution

Controller selectors shouldn't need to populate the route data. Routing will populate the route data. The way the default pipeline works is something like this:

Routing runs - finds a matching route and populates the route data with values like "controller", "action", other parameters The controller selector runs - looks at the route data for the "controller" route parameter and uses that controller name to figure out what controller type to use

The framework then uses the selected controller type to dispatch the request

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top