You can add a web API controller to your MVC project. In Solution Explorer, right-click the Controllers folder, select Add Controller, and then select Web API Controller.
The only thing you need is routing - I believe that the "empty" MVC 4 project by default includes a web API route, so you should be fine. Find something like:
routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );
But if you want to convert an existing MVC controller to a web API controller, there is no automatic way to do this.
source share