Is there a way to change the naming convention for controllers in ASP.NET MVC?
What I want is to name my controllers InicioControlador instead of
Yes, ControllerFactory is the best solution of your problem.
public IController CreateController(RequestContext requestContext, string controllerName)
{
BaseController controller;
switch (controllerName.ToLower())
{
case "product": case "products": controller = new MyProductController(); break;
case "home": controller = new MyHomeController(); break;
case "account": controller = new MyAccountController(); break;
default: controller = null; break;
}
return controller;
}
This is my first ControllerFactory - but it is very stupid :) You must use reflection and avoid this ugly switch.