I want to be able to access the following through one route constraint declaration:
/picks
/picks/{teamID}/{week}
/picks/save/{teamID}/{week}
This does not work for the second request: /picks/{teamID}/{week}
routes.MapRoute(
"picks",
"picks/{action}/{teamID}/{week}",
new { controller = "Picks",
action = "Index",
teamID = UrlParameter.Optional,
week = UrlParameter.Optional });
It seems to me the action should be defaulted to Index since I don’t supply one, but I’m assuming it’s actually trying to find the action {teamID} (which is a number).
How do I make this constraint handle all 3 scenarios?
You just have to omit the action from the rout string for the first route:
Remember to place more specific routes on top of more generic ones.
Eg:
The routes are tryed in the order they are added.