Does ASP.NET Web API's DefaultHttpControllerSelector populate its routing dictionary on every request?

StackOverflow https://stackoverflow.com/questions/14387778

문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top