Thanks to the guys who are infinitely smarter than me that did MVCContrib, adding RESTful behavior (using SimplyRestfulRouteHandler) to a .NET MVC app is pretty simple.
- Download the MVCContrib libraries (I downloaded the source because I like to break stuff)
- Open up your ASP .NET MVC application and add a reference to the MVCContrib.dll
- Open up the Global.asax.cs and add the following line inside the ResgisterRoutes method:
HTTP verb: [GET] (for show)
HTTP verb: [PUT] (for update)
HTTP verb: [POST] (for create)
So what if you wanted to address hierarchy with the object using the same URI scheme? Let's say you wanted to get all of the addresses for a particular person and addresses were a child of person:
HTTP verb: [GET]
Thanks to the slick implementation of the RouteHandler all you have to do is add another call to BuildRoutes using an overload that accepts an "areaPrefix"
So now you can use:
https://api.mydomain.com/v1/People/1/addresses <-- collection
https://api.mydomain.com/v1/People/1/addresses/3 <-- single
https://api.mydomain.com/v1/addresses/3 <--single no context