REST has been such a popular buzzword over the last couple of years (or so), and when ASP.NET MVC rolled out, everyone connected REST with ASP.NET MVC. I also fell in noise and due to a lack of my knowledge, my understanding of REST was simple:
REST = SEO / User Friendly URLs
But it is much more. And the more I learn about REST, the less I associate ASP.NET MVC with it. This, of course, is much closer to REST than to WebForms. So the truth is actually quite the opposite:
REST ≠ SEO / User Friendly URLs
And if your default route, defined as controller/action/id , is definitely not RESTful.
Let me explain my problem with this understanding.
If ASP.NET MVC was RESTful, we would not have a default route defined as:
controller/action/id
but rather
resources/id /* that would have to use HTTP methods GET/PUT/POST/DELETE */
So, instead of having (also providing an HTTP method with a request):
/product/index/1 /product/create /product/delete/1 /product/update/1
it should be (an HTTP method is also provided here)
/products/1 /* GET */ /products /* POST */ /products/1 /* DELETE */ /products/1 /* PUT */
Now it will be RESTful. Well, that is really possible. And if you do it completely RESTful, it would also mean that you should use Ajax , because the PUT and DELETE methods cannot be executed using browser-only queries (this is not entirely true 1 ). Thus, modern Ajax applications can be completely RESTful.
Ajax is a client technology and actually has nothing to do with ASP.NET MVC. The fact is that ASP.NET MVC can be run as a fully RESTful application. The means of achieving it (Ajax) does not matter. (thanks to Darin Dimitrov)
Main question
Why do we see ASP.NET MVC as a RESTful structure, especially related to its URL routing? Why didn't they set a default URL route to ensure RESTfulness? I am not looking for argumentative answers, but those that actually answer the question - how did this attitude come to life ... Perhaps I am still not wise enough and still perceive this as a lack of my knowledge of both.
1 Updated Information
In fact, you do not need to use Ajax to fully implement the RESTful architecture. Asp.net MVC supports (starting from version 2) the HTTP overriding method, that is, you can issue PUT or DELETE methods using browser forms. All you have to do is add an extra hidden field, for example:
<input type="hidden" name="X-HTTP-Method-Override" value="DELETE" />
The Asp.net MVC structure will be able to understand a POST request such as a DELETE request, and the HttpDeleteAttribute action selector will also understand it as a delete request. HTTP method overriding FTW!