Reputation: 39268
I'm using the default routing below.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = "17" }
The problem is that it's very rigid. The default action will be Index in each case. (And the default controller will be Home.)
I'd like to route to action IndexHey when controller Uno is targeted and to action IndexHoopla when Duo is. What is the syntax for that?!
(I've played around with different additional route mappings but didn't got it to work and now I'm sick and tired of trial-and-erroring.)
Upvotes: 0
Views: 53
Reputation: 100610
The easiest approach is to have specific routes for specific controllers before generic one like
routes.MapRoute(
name: "Uno",
url: "Uno/{action}/{id}",
defaults: new { controller = "Uno", action = "IndexHoopls", id = "17" }
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = "17" }
Upvotes: 1