Introduction to Web API:-

ASP.Net Web API is a framework for building HTTP service for broad range of clients like browser, mobile device, desktop application and tablet apps.

HTTP is simple, flexible, and ubiquitous using this Web API is created to expose the service on top of .Net framework. It is alternative for the WCF user, who need only HTTP and need complete control on it.

In today’s world, most of the application used the HTTP and JSON as their communication channel between server and client. Web API one among the service to good on this communication. Web API are excel in accepting and generation the structure data like JSON and XML.

Many of the ASP.MVC concepts like controller, actions, filters, model bindings, dependency injections are same in Web API also. This makes application combine MVC and Web API are well integrated.

WebAPI is an ideal platform for building pure HTTP based services where the request and response happens with HTTP protocol. The client can make a GET, PUT, POST, and DELETE request and get the WebAPI response appropriately.

       
    public class ValuesController : ApiController
    {
        // GET api/values
        public IEnumerable Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }