Sitecore 8.2 rev 160729
My understanding is that, as of Sitecore 8.2, you no longer need to call .MapHttpAttributeRoutes()
because it's now included (in fact, it'll throw an error if you do). However, Sitecore is not picking up my ApiControllers using attribute based routing.
public class SampleController : ApiController
{
[Route("-/api/sample/test"), HttpGet]
public string Test()
{
return "Hello World!";
}
}
The above route does not appear in the route tables, and the URL gives me a 404.
Do I need to tell Sitecore which assemblies to look for routes in, or is there an additional configuration step I'm missing?
string
instead of aContentResult
. Unless there is something special in Sitecore that allows controller actions to have a value type as the return type of an action, then this may be your culprit. I would expect that you would see "No action method found" errors, however, so I don't think this is your only issue – Zachary Kniebel Jan 25 '17 at 22:09string
. I believeContentResult
is only a thing for MVC Controllers. – Ben Lipson Jan 25 '17 at 22:18