Controller:
public class ExampleController : Controller
{
private readonly ISitecoreContext _sitecoreContext;
public ExampleController ()
{
}
[System.Web.Http.HttpGet]
// GET: Manifest
public JsonResult Test()
{
return Json("test");
}
}
Register Route Pipeline:
public class RegisterTestApiRoute
{
public virtual void Process(PipelineArgs args)
{
RouteTable.Routes.MapHttpRoute(
"testApi",
"api/testing/{controller}/{action}"
);
}
}
Patching route in config:
<pipelines>
<initialize>
<processor type="TestProject.Pipelines.RegisterTestApiRoute, TestProject" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
</initialize>
</pipelines>
With all above in place the following default Sitecore webapi route works fine:
http://localsitecore/api/sitecore/example/test
but my custom route
http://localsitecore/api/testing/example/test
returns below error:
{"Message":"No HTTP resource was found that matches the request URI 'http://localsitecore/api/testing/example/test'.","MessageDetail":"No type was found that matches the controller named 'example'."}
I'm not sure why controller is not found, in a properly compiled code, I've tried below:
- Restarted IIS
- killed worker processes
- cleared Visual Studio temp files
No luck..
even browsed my project dll with reflector, the controller exists..
Am I missing anything here...?