I\'m trying to navigate to a page which its URL is in the following format: localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx
I\'ve added a new route i
In my case, the routing was defined as:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "WarehouseController" }
while Controller needs to be dropped in the config:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{*catchall}",
defaults: new { controller = "Warehouse" }
In my case it was a case of over-aggressive caching by the WebHostHttpControllerTypeResolver.
Fix:
Delete all files (or in my case just any files named "MS-ApiControllerTypeCache.xml") under this path:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root
Restart the app pool
credit: https://sitecore.stackexchange.com/questions/9897/webapi-controllers-not-being-found-in-sitecore-8-2
In my case, the controller was defined as:
public class DocumentAPI : ApiController
{
}
Changing it to the following worked!
public class DocumentAPIController : ApiController
{
}
The class name has to end with Controller!
Edit: As @Corey Alix has suggested, please make sure that the controller has a public access modifier; non-public controllers are ignored by the route handler!
In my case I wanted to create a Web API controller, but, because of inattention, my controller was inherited from Controller instead of ApiController.
Another solution could be to set the controllers class permission to public.
set this:
class DocumentAPIController : ApiController
{
}
to:
public class DocumentAPIController : ApiController
{
}
In my case I was seeing this because I had two controllers with the same name:
One for handling Customer orders called CustomersController
and the other for getting events also called CustomersController
I had missed the duplication, I renamed the events one to CustomerEventsController
and it worked perfectly