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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With