tags:

views:

174

answers:

1

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 = "" });
+4  A: 

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...

Tomas Lycken
Thanks. I just realized that I'd pasted that in on accident before posting it.
RG
The routing debugger mentioned popped up a couple times on my reader, I totally forgot about it. Thanks!
RG