Search code examples
asp.netasp.net-mvcasp.net-mvc-5asp.net-mvc-routingurl-routing

Controller Class without Controller at the end of the name?


For the reasons that are not important to the question, I would like to know how to make my controllers / routing work in ASP.NET MVC5 if my controller class names do not end in Controller as per convention? Do I need to manually register them somewhere?


Solution

  • The Controller suffix is baked into the the ControllerDescriptor and ControllerTypeCache classes making it hard to override. One way that comes to mind is to write a custom controller factory and override the GetControllerType method.