Looks like the route is empty?
e.g.: [Route("customers/{customerId}/orders")]
See: http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2
And a little bump. Had it working, then after a conflict it stopped working. Did you find out what the problem was?
I don't know if this is the issue but if you are using System.Web.Mvc.RoutePrefix and System.Web.Mvc.Route instead of System.Web.Http.RoutePrefix System.Web.Http.Route the routes will not be registered for your ApiControllers. So, check your attributes and then it should work just fine.
/Marcus
Like Marcus is saying, it is important to add routes the right way, that is descibed in the linked document
This adds a normal default route
routes.MapRoute(name: "api", url: "api/{controller}/{action}", defaults: new { controller = "Login", action = "index" });
and this adds a default route for webapi
routes.MapHttpRoute(name: "API Default",routeTemplate: "webapi/{controller}/{id}",defaults: new { id = RouteParameter.Optional });
ok, my 2 cents ;) We discovered in our projects, that 4.5.1 and episerver and webapi somehow didn't play well together.. routing was not working
Interesting Valdis, we are using WebApi2 in a 8.1 project with MVC5 and it seems to work fine
We're using .NET 4.5.1. I switched to IIS Express and it started working, then switched back to regular IIS and it worked. A bit spooky, but I'm happy... :)
Erik, originally - when you where on IIS with 4.5.1 - it didn't work? You switched to express, then back - and it started to work?
Valdis, it worked first. But "suddenly" it stopped working (TFS conflicts, EPiServer updates etc). When switching to IIS Express and started to work, and switching back it worked again. Still havent figured out what the problem was, and I will not try to unless it happens again. :) Haven't changed .NET Framework during the process.
I've had a similar problem - I wanted to extend the new ServiceAPI with my own additional services - and added them using attribute routing - and no matter what I did, it simply wouldn't work...
Then, after updating my project to .NET 4.5.2 it started working all of a sudden (before it was 4.5.1). If it's the updated .NET or just the included reboot and restart that made it work I don't know.
Trying to get Web API working but I'm just getting 404s no matter what I do.
Any ideas? I'm all out...