I'm not sure why but my api route just isn't working? What I do is click on the add controller, select Web API 2 controller with actions using EF (so that it builds it for me) select the model and context and click Add.
WebApiConfig
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
ProductsController (ApiController)
public IQueryable<Product> GetProducts()
{
return db.Products;
}
This would imply that by going to /api/products it would display a json format of products ... it doesn't. What I DO get is a 404: The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. I tried putting a breakpoint in too and that doesn't even get hit. So I'm a little confused.
I do have custom Web Route configs, which I thought could have been the problem, but when commenting them out still this happens. Is scaffolding missing something?
Thanks for any help
IEnumerableinstead ofIQueryable. maybe this is the issue?