namespace UrlsAndRoutes { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { Route myRoute = routes.MapRoute("AddContollerRoute", "Home/{action}/{id}/{*catchall}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new[] { "URLsAndRoutes.AdditionalControllers" });
myRoute.DataTokens["UseNamespaceFallback"] = false; } } }
The MapRoute method returns a Route object.
To disable searching for controllers in other namespaces, take the Route object
and set the UseNamespaceFallback key in the DataTokens collection property to false.
This setting will be passed along to the component responsible for finding controllers,
which is known as the controller factory. The effect of this addition is that requests
that cannot be satisfied by the Home controller in the AdditionalControllers folder will fail.
0 comments:
Post a Comment