ASP.NET MVC 4 includes ASP.NET Web API, a new framework for creating HTTP services that can reach a broad range of clients including browsers and mobile devices. ASP.NET Web API is also an ideal platform for building RESTful services.
ASP.NET Web API includes support for the following features: Continue reading
The Web Api (
Application Programming Interface) feature is based on a special kind of controller to an MVC framework application.
An api controller distinguishes itself from the normal controllers by the following :-
- Action methods return model, rather than an ActionResult in MVC, objects.
- Action methods are selected based on the HTTP method used in the request.
The model objects that are returned from an API controller action method are encoded as
JSON/XML based on the browsers used and sent to the client.
Both are accessible via HTTP/REST and both works in the way to skip the serialization in order to isolate logic which could impact the performance results.
Both services implements GET and POST requests:
- GET request to return a string with current time
- POST request to accept a data and return back the same data in the stream
The results showed that WCF is faster than WebAPI when sending GET requests but slower when executing POST request in non-chunked mode.
we need to answer a couple of questions:
- What is the purpose of the WebAPIs?
- Why do we need REST HTTP services? What’s wrong with SOAP-over-HTTP?
- Why did the WebAPIs move from WCF to ASP.NET MVC?
- Is there still a use for WCF? When should I choose Web APIs over WCF?
- Is WCF done? Does WebAPI replace WCF? Should I stop using WCF HTTP?
- Why is WebAPI part of ASP.NET? Wasn’t WebAPI originally a WCF framework?
- If WebAPI is part of ASP.NET, why don’t I just use MVC? What does WebAPI give me over MVC?
“WCF remains the framework for building services where you care about transport flexibility. Web API is the framework for building services where you care about HTTP.”
This article describes the differences between the Web API and Windows Communication Foundation (WCF). And also describes how to choose between WCF and Web API.
What is the ASP. NET Web API
The ASP. NET Web API is a framework that uses the HTTP services and makes it easy to provide the response to the client request. The response depends on the request of the clients. The Web API builds the HTTP services, and handles the request using the HTTP protocols. The request may be GET, POST, DELETE, PUT. We can also say that the ASP. NET Web API:
- Is an HTTP service.
- Is designed for reaching the broad range of clients.
- Uses the HTTP application. Continue reading