Hosting an ASP.NET Web API in an MVC web application makes perfect real sense if you mainly use the API to create AJAX calls from your web client. The presence of an API and a web application in one project eliminates problems with cross-domain Ajax calls, which requires JSONP. But the ASP.NET Web API can easily support JSONP, if necessary, using custom formatting, such as JsonMediaTypeFormatter, available from WebApiContrib .
The ASP.NET Web API simplifies the development of the REST API. You use the same conventions as controller development in MVC. To create it separately from your web application, just create an MVC 4 project and create your controllers using ApiController instead of the standard controller for rendering Views. Then just deploy the application, just like any web application, to IIS (you can also run ASP.NET web APIs yourself in a bit of a Windows service). Here is an example on the official ASP.NET Web API website that calls the REST API developed by the ASP.NET Web API from a console application . There are many more examples on this site.
source share