I am waiting on the next set of bits to finish the simply restful routing stuff for ms mvc. I am currently working a new better implementation for monorail which I will port over to contrib when its ready. The biggest up side will be rule definition sets get put into a container and the container will sort, organize, and build the routing rules for you. This accomplishes a couple things. First you no longer have to manually maintain your routing rule order, the builder will figure out the correct order from the most specific to the most generic. Secondly this will handle nested controllers which is currently a huge pain point for me. And finally, I do enumerate all the controllers in the application so your most generic rule <controller>/<action> will not match nested controllers and controllers in "areas". So you won't be able to accidentally go to http://localhost/roles/123/edit when RolesController is defined in the admin area.
So manually creating the route with the builder could look something like this.
routingBuilder.NewSimplyRestfulRouteForController<ContactMethodsController>()
.FromSimplyRestfulParentController<PeopleController>()
.ToController()
.ToRequiredString("type")
.AcceptingValues("phone","email","address")
.Register();
which make the following url: http://localhost/people/123/contact-methods/phone/456/edit match the Edit action on the ContactMethodsController with parameters for personId, contactMethodId, and type.
I will also offer support for using attributes on your controllers to achieve registration as well, assuming the order you define attributes is respected by the compiler, otherwise the syntax will get ugly.
[SimplyRestful,
RestfulParent(typeof(PeopleController)),
RestfulController,
RequiredString("type", new string[] {"phone", "email", "address"})]
public class ContactMethodsController : SimplyRestfulBaseController
{
public void Edit(int personId, string type, int contactMethodId)
{
}
/// matches http://localhost/people/123/contact-methods/phone/search?q=555
[ListingAction]
public void Search(string type, string q)
{
}
/// matches http://localhost/people/123/contact-methods/email/456/detail
[EntityAction]
public void Detail(int personId, string type, int contactMethodId)
{
}
}
routingBuilder.RegisterRoutesFromAssembly<HomeController>();
routingBuilder.BuildRoutes(routeCollection);
I have a good bit already worked out for monorail for one of my current projects. There are still some quirks but I am liking it. I really look forward to see what is in store in the next ctp.