ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
In this post, we would have an introduction to one of the most popular frameworks developed for RESTful services. We would be looking at WEB API, What is WEB API, it’s advantages and much more.
An Introduction to ASP.NET WEB API
What is WEB API?
WEB API is a platform for building RESTful applications with .NET framework. It makes easy to build HTTP services on a wide range of clients that includes mobile devices and browsers. So using WEB API we can create HTTP services that support XML or JSON string. Also, we reach a broader range of clients. Considering the number of mobile applications and Single page applications developed these days we need a framework that can provide data to these applications seamlessly. And so is this framework that has been very popular having done this.
WEB API was introduced in ASP.NET MVC 4. Though this could be used with web forms as well. But its structure is well adapted to ASP.NET MVC framework. A person who is familiar to ASP.NET MVC would be in a position to start working on WEB API.
So we just read Web API is used build Restful applications. But what is REST anyways? Let us read and understand as to what REST is.
What is REST?
REST stands for Representational State Transfer. We can exchange data using REST of distributed networks. We use HTTP protocols for the communications just like we have been doing with the WCF services and web services till now. WEB API offers us much more, one such thing is we can use CRUD (Create- Read -Update -Delete) operations with HTTP using WEB API by implementing the following:
- GET: This is used to retrieve the data from the remote source.
- PUT: This is used to update the data on the remote server.
- POST: This is used to save/create data which could be transferred to some other location.
- DELETE: As the name implies this is used to delete data from the remote server.
In terms of CRUD operations:
- GET is the Read from CRUD,
- PUT refers to update in CRUD,
- POST refers to Create in CRUD and of course,
- DELETE refers to Delete in CRUD.
Why Choose WEB API?
We have a couple of reasons as to why we should go for WEB API. Some of them are listed below:
- WEB API supports a wide range of media types including XML and JSON.
- WEB API supports route capabilities.
- It supports Representational State transfer(REST).
- Although this is a part of the .NET framework it is an open source as well. Again here is an advantage.
- WEB API uses the basic protocols such as HTTP and formats including JQUERY, JSON, and XML.
- It supports CRUD operation on the data.
- Using this is easier to implement in ASP.NET MVC applications because of the similar structure.
- It provides better HTTP experience.
In this post, we just read about WEB API. What it is, its advantages over the existing services present. In the next post, we would be creating a basic WEB API in ASP.NET to further look at its features. I hope this post is useful to the developers who have just started to know the basic of web API.
Have something to say? Leave a comment or feedback.