Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the future of ASP.NET MVC framework after releasing the asp.net Web API

I have been using asp.net MVC for around 1.5 years, am enjoying its capabilities, and have deployed many successful web applications, but I'm currently reading about the asp.net Web API technology. And, I find the following:

  1. I can implement any functionality that I used to implement using MVC; using the new Web API and in a more lightweight approach.

  2. It is easier to develop web services using the Web API comparing the asp.net MVC.

So, will the asp.net Web API take over asp.net MVC in the future, or each technology will have its own area to grow in, or should we consider using both of them in the same web application?

like image 487
john Gu Avatar asked Jul 23 '12 22:07

john Gu


2 Answers

Besides the @jmoerdyk's answer, I would like to point something out:

The key is to understand the goal of each technology:

  • Web API.

    This will be the new API for creating web services, this is an alternative to traditional XML services and WCF services, so it's worth pointing out first the main difference between WEB API and the rest of the Web service frameworks.

    The primary difference between Web API and WCF/ASMX services is that it's not based on SOAP it's based on HTTP Therefore you can take advantage of all the HTTP features like:

    • It contains message headers that are very meaningful and descriptive - headers that suggest the content type of the message’s body, headers that explain how to cache information, how to secure it etc.
    • use of verbs to define the actions (POST, PUT, DELETE..)
    • it contains a body that can be used to send any kind of content
    • It uses URIs for identifying both information paths (resources) and actions

    That was the main goal of the Web APIs, known back then as the WCF Web APIs: to stop looking at HTTP through the eyes of WCF - as just a transport protocol to pass requests. Rather, it allows us to look at it as the real application-level protocol it is – a rich, interoperable, resource-oriented protocol. The purpose of the Web APIs was to properly use URIs, HTTP headers, and body to create HTTP services for the web, and for everyone else that wished to embrace HTTP as its protocol and lifelong friend.

    Take a look to this article for more information: http://www.codeproject.com/Articles/341414/WCF-or-ASP-NET-Web-APIs-My-two-cents-on-the-subjec

    So basically the Web API could actually be compared against WCF or XML Services

    If you are wondering what's going to happen with WCF?

    So the fact was we had too many options and therefore too much confusion. What were we to do? We merge teams! (Kind of reminds us of the time of LINQ-to-SQL and Entity Framework, WCF and Ado.Net Data Services and other such examples). So the WCF team and the ASP.NET team joined forces and created a new framework focused on the world of REST/Hypermedia/HTTP services for the web world and thus came out the ASP.NET Web APIs.

  • MVC

    Now that you know what's the goal of the Web API, then it should be easier to say why MVC contains additional functionality to render views primarily.

    Your concern is based on the fact that WEB API is actually based on MVC, but their goals are different

    On the other hand, the ASP.NET MVC infrastructure with its elegant handling of HTTP requests and responses, and its support of easy-to-create controllers seemed like the proper way to go for creating this new type of services

like image 173
Jupaol Avatar answered Nov 08 '22 22:11

Jupaol


No, they don't really do the same thing.

Web API is really only for generating JSON, XML or other text based responses for implementing REST based APIs. MVC can do that as well, but the new Web API appears to make it easier, particularly with the automatic content type negotiation.

What MVC does that Web API is not intended for is generating full or partial HTML pages with Views and such.

So each one has their own purpose in the ASP.Net framework and not likely to surpass the other.

like image 33
jmoerdyk Avatar answered Nov 08 '22 20:11

jmoerdyk