“True” REST routing via MVC 4 Web API

hamid

New Member
Long-time lurker, first time poster so go easy on me ;)TL;DR Summary: Can I configure MVC Web API routing for HTTP GET, PUT & DELETE?I've been looking into replacing our old Data Access Layer (a DLL based on DataSets and TableAdapters) with a private API, with a view to creating a public API if it's successful. I've done some work with MVC 4 to refresh our frontend, and loved working with it, so it seems sensible to explore the "Web API" project type before diving into WS- or WCF-based libraries.An initial demo allows me to return XML/JSON nicely, for example:\[quote\] //service.url/api/Users\[/quote\]... returns a list of users, while a specific user's details can be accessed via:\[quote\] //service.url/api/Users/99\[/quote\]So far, so RESTful. However, in order to truly map URIs to resources I want to do an HTTP PUT (new user) or HTTP DELETE (remove user) to the the URI listed above. In all of the examples I've seen for these projects, along with the Scaffolds provided in Visual Studio, this convention is followed:\[quote\] //service.url/api/Users/Create //service.url/api/Users/Delete/99 //service.url/api/Users/Update/99\[/quote\]... and so on. This feels like side-stepping the issue to me, which is a shame when what's there has been put together so nicely!Any thoughts on how best to approach this?
 
Back
Top