MapMvcAttributeRoutes requires the list of controllers in order to enumerate the attribute routes. The current implementation doesn't allow customizing the service used to provide the controller list. As a result, we always call the ASP.NET BuildManager, which means only code running in an ASP.NET app domain can call MapMvcAttributeRoutes without throwing an exception.
We often suggest people unit test RouteConfig.Register, but because of this problem, anyone using attribute routing can't unit test even their traditional routes without significant workarounds.
Ideally, we'd change the implementation that gets the controller list to make that a replaceable service so that unit testing is feasible here.
We often suggest people unit test RouteConfig.Register, but because of this problem, anyone using attribute routing can't unit test even their traditional routes without significant workarounds.
Ideally, we'd change the implementation that gets the controller list to make that a replaceable service so that unit testing is feasible here.