Why use ASP.Net Web API
So you are here because you have come across this awesome new feature in .NET called Web API and you do not know why and when to use it. This is a simple yet important question when you start designing any new applications that needs to be able to communicate with a server to send and retrieve data. The main thing that will influence your decision is whether you have complete control of all clients that will be integrating with your system, or if you would like one standard approach for all possible future applications to integrate with your system.
Classically for web applications you would have done post backs that will connect to your database and render the appropriate HTML for the client and everyone was happy. In recent years with the progress of web technologies and faster connections our clients have started to expect web based systems that are faster and more responsive, one way to solve this was by building AJAX requests that load portions of the data at a time which causes pages to load faster and the client to experience a system that is more responsive. Because of this, different frameworks where designed and created to solve this problem. This is where Web API fits into the picture, in my opinion it is one of the best frameworks to ever see the light of day. It is simple to implement, it is .NET based, it supports multiple forms of data encoding and decoding out of the box so you do not need to write or include any other libraries, and it already supports the needed HTTP verbs that we need for AJAX and any other RESTful requests we want to make in the future.
We have touched on this briefly but to get into a bit more detail let's look at some examples of where and why you would use Web API
- You are a .NET developer.
- You want one easy way to access your database from multiple platforms, but control the way the data is accessed.
- You are creating a Mobile Application and you want a Web Application for supporting the mobile application.
- You have a Web Application and want other systems or applications to integrate with your system.
This list can go on for ever, there is so many different reasons for using Web API that I just can't list all possible reasons.
Please feel free to contact me if you have any questions, or check out the future entries to this blog for examples of how to use this.