Reputation: 4753
Is it possible to create a specific routing for all the controllers in a specific namespace?
For example, I have the namespace "Report" which contains Report1, Report2, Report3, ..., ReportN.
Currently using the default route
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
the mapping is :
localhost:12345/Report1
localhost:12345/Report2
localhost:12345/Report3
...
localhost:12345/ReportN
I would like to change it to :
localhost:12345/Report/Report1
localhost:12345/Report/Report2
localhost:12345/Report/Report3
...
localhost:12345/Report/ReportN
but only for the Controller that are in the namespace "Report"
Upvotes: 0
Views: 54
Reputation: 2213
Add the following line:
routes.MapRoute(
"Default",
"Report/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] {"Website.SomeNamespace.Controllers"}
);
Upvotes: 1