I'm building my first app using web api, and I've stumbled upon a problem that I can not find information on.
Using sample controller to test if its working:
public class TestController : ApiController
{
// GET api/test
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
WebApiConfig.cs:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
Every time I try to call the service using http://localhost:59502/api/test
I am getting
<Error>
<Message>
No HTTP resource was found that matches the request URI 'http://localhost:59502/api/test'.
</Message>
<MessageDetail>
No type was found that matches the controller named 'test'.
</MessageDetail>
</Error>
Can someone point out what am I doing wrong?