ASP.Net MVC4 – What Exactly Is Web API?

asp.netasp.net-mvc-4

I know what a Web API is.
I've written API's in multiple languages (including in MVC3).
I'm also well practiced in ASP.Net.
I just discovered that MVC4 has "Web API" and without going through the video examples I can't find a good explanation of what exactly it IS.
From my past experience, Microsoft technologies (especially ASP.Net) have a tendency to take a simple concept and wrap it in a bunch of useless overhead that is meant to make everything "easier".
Can someone please explain to me what Web API in MVC4 is exactly? Why do I need it? Why can't I just write my own API?

Best Answer

ASP.NET Web API is a "non-opinionated" framework to build HTTP Service regardless of REST or RPC. It is Microsoft's best implementation of RFC 2616 (HTTP Spec).

Certainly you can build your own API but ASP.NET Web API:

  • Built based on the Russian Doll model which allows for lego-like modules to be added to the HTTP pipeline
  • Makes HTTP first class citizen so all common headers are strongly typed (not just name value) and helps with parsing them
  • Allows for both ASP.NET (IIS) hosting or self-hosting
  • supports content negotiation, media types, ...
  • Is Async from top to bottom
  • Uses a similar approach for clients with HttpClient
Related Topic