I have a Web API with 2 Controllers: ValuesController and MyController
I initially created ValuesController and I access it using MyUrl/api/values, this works fine.
I then added another controller MyController and in the comments that were generated by Visual Studio, it says that I access it using api/. When I try api/MyController, it doesn't work, I get a page that reads No HTTP resource was found that matches the request URI '/api/MyController'.
My WebApiConfig looks like this:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
How do I access the GET in my new controller? Do I need to modify the WebApiConfig?
Thanks in advance for any help.