Using the library AttributeRouting, I was able to configure attribute routing to use a custom route handler (inheriting MvcRouteHandler
):
routes.MapAttributeRoutes(cfg =>
{
cfg.UseRouteHandler(() => new MultiCultureMvcRouteHandler());
}
);
Also, before MVC5, it was possible to change the route handler of any existing route:
(routes["myroute"] as Route).RouteHandler = new MyCustomRouteHandler();
With MVC5 using attribute routing, the routes collection contains internal classes (RouteCollectionRoute
for example) and it doesn't seem to be possible to change the route's RouteHandler
property.
How can I change the default route handler used when working with attribute routing in MVC5.1 ?