Difference between ASP.NET MVC 4 Web Api and REST

2019-05-01 16:02发布

问题:

I saw that ASP.Net MVC4 WebApi exposes services as a Rest ones.

But what is actually the difference between normal Rest and ASP.Net MVC4 WebApi?

回答1:

I'm not sure what you mean by normal Rest.

REST is a paradigm.

HTTP is a protocol that follows that paradigm.

ASP.NET Web API allows developers to write ASP.NET applications that can be accessed via HTTP and adhere to the REST paradigm. While you could create a REST API without Web API, Web API provides a ton of features that will remove a lot of the pain associated with creating a truly RESTful API in ASP.NET.

apigee has many great resources for REST API best practicies.



回答2:

Are you asking about the general REST standard or the way that REST has been done traditionally on the Microsoft platform prior to the MVC4 Web API? I am thinking you are approaching this as the second one.

The updated approach in MVC4 gives you more REST capabilities without the WCF model. Here is a recent post on the subject: http://mattmilner.com/Milner/Blog/post/2012/02/28/WebAPI-or-WCF.aspx.