I'm looking for a routing option similar to the nested RESTFul routes functionality available through Rails. The SimplyRestful project on MvcContrib doesn't appear to be active any longer nor does it appear to be current with the 1.0 MVC release.
This is the uri scheme I'm looking for,
/Activity/10/Task/1/Edit or /Activity/10/Task/Edit/1
I simply haven't been able to get it to work and all the documentation I've run across describes the non-nested scenario. It doesn't seem like it'd be that difficult....
This is what I've been working with...
routes.MapRoute(null, "Activity/{activityId}/Task/{action}/{id}", new { controller = "Task", action = "Edit", activityId = "", id = "" });
Add a default value for activity
:
routes.MapRoute(null,
"Activity/{activityId}/Task/{action}/{id}/{activity}",
new {
controller = "Task",
action = "Edit",
id = "",
activityId = "",
activity = "" });
Remember also that this route will only pick up urls on the form
/Activity/10/Edit/1/theActivity
while your example
/Activity/10/Edit/1
will be picked up by the default route, setting the route values to
controller = "Activity"
action = "10"
id = "Edit/1"
Phil Haack's Routing Debugger for ASP.NET MVC is extremely useful for figuring out how to work these things...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With