Is it possible to have the default value for a route parameter be another value from the route?
e.g. something like:
routes.MapRoute(null,
"{controller}/{action}/{parentid}/{currentid}",
new { controller = "Home", action = "Display", currentid = "{parentid}" }
);
parentid is compulsory and will always have a value. If no value has been specified for currentid I’d like it to take the value of parentid.
I don’t know if this functionality is supported out of the box but you could always write a custom route to implement it:
and then register this route:
Now assuming you have defined the following controller:
you could request it by:
/home/display/123-> parentid=123 and currentid=123/home/display/123/456-> parentid=123 and currentid=456