Introduction
Today the web based application alone is not enough to reach the customers and real world as era of mobile devices has started.Customers have become very smart and they are using smartphones , tablets etc. devices in its daily life.These devices also have a lot of apps for making the life easy. Actually, we are moving from the web towards apps world.
Now every customer app need to to get, update and manipulate data.Here a Web API comes into picture. API stands for Application Programming Interface it is similar with online web services which client apps can use to retrieve and update data.
ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers , mobile and desktop devices.
Implementation
To Implement ASP.NET Web API we have a class that is called as ApiController that is same as MVC controller but in this the ActionMethod map to the HTTP methods.
ValuesController is an example WebAPI controller.
Its has different HTTP methods PUT,GET,POST,DELETE to manipulate data.
The above four methods can be used to CRUD operations as follows:
=>GET to get data at specified URI .
=>PUT to update data data specified URI .
=>POST to creates a new data at specified URI
=>DELETE to delete a data at specified URI
The above four methods accepts input according to their type(as defined by the provider) and then return JSON and XML based responses.
The routing in this is quite similar to MVC controllers i.e http://hostname/api/controller/id
From an Web application we can use jQuery to directly access the Web API by calling the API using the getJSON() .
0 Comment(s)