You can implement your own factory controller class, which translates the name of the controller before initializing it. For example, you can store translations in a resource file or in a database. The easiest way to do this is to inherit from DefaultControllerFactory and overwrite the CreateController function.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace System.Web.Mvc
{
class CustomControllerFactory : DefaultControllerFactory
{
public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
{
return base.CreateController(requestContext, controllerName);
}
}
}
The final step would be to register the implementation of your factory controller when the application starts (in Global.asax).
namespace MyApplication
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
ControllerBuilder.Current.SetControllerFactory(typeof(CustomControllerFactory));
}
}
}
source
share