I have an MVC 4 project sitting atop an N-tier application. I now have a requirement to to be able to consume the application programmatically. I have created a new Web API proj
I just did the same thing yesterday. I have in the same MVC 4 project regular Controllers and ApiControllers.
You need to add the routing in the Global Asax for WebApi :
WebApiConfig.Register(GlobalConfiguration.Configuration);
Take a look at the WebApiConfig :
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Don't forget also to add the Nuget Packages for WebApi (if you don't have them already). In my case I did not had them because my project was originally MVC 3 and was later upgraded.