Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of ASP.NET Web API over ASP.NET MVC [closed]

I frequency experience that Web API has some limitations and some disadvantages that not exists in "ASP.NET MVC".

For instance, ASP.NET Web API doesn't support [OutputCache] attribute "Out of the box" so i had to install NuGet add-on for supporting it.

My question is, why should i choose to work with ASP.NET Web API if i can choose ASP.NET MVC that as far as i know can do whatever WEB API can do and even more?

like image 491
Omtechguy Avatar asked Feb 17 '14 14:02

Omtechguy


3 Answers

ASP.NET MVC is an MVC framework for building web aplications. ASP.NET Web API is a framework for building RESTful services. That's the main difference of the two frameworks. They have been built for different purposes and they should be used for the purpose they have been built.

A comparison between ASP.NET Web API and WCF would have been more reasonable, because both are used for the implementaion of SOA (Service Oriented Architecture) solutions. On the other hand, I don't think that we should relate ASP.NET Web API with ASP.NET MVC.

like image 175
Christos Avatar answered Sep 28 '22 15:09

Christos


ASP.NET MVC is optimized to return content to a web browser over HTTP and is based on the ASP.NET runtime (system.web) that has been around for > 10 years.

ASP.NET Web API is a HTTP application framework that does not care what client you are serving. It is built on a new Http stack that can be used for both the client and server side.

Both frameworks can produce RESTful applications, neither are particularly optimized for it.

like image 41
Darrel Miller Avatar answered Sep 28 '22 14:09

Darrel Miller


MVC is a framework for develop web application but Web api is for develop REST service. we can compair WebAPI with Wcf because both are for develop for services.

when we use WebApi then we no need to add attribute on method like Get,Put etc but we have to make method name start with GetEmployee,PutEmployee,PostEmployee etc..

authentication is more simple we can authenticate user at entry point of the service,no need to authenticate at every method or controller. only we have to add "Authenticate" attribute on method or controller as per requirement.

like image 45
J R B Avatar answered Sep 28 '22 14:09

J R B