Question

I need your help to understand how can I have an URL in french and one in english that redirect to the same controller in MVC4?

In other words, I have a controller Speciality which have a controller MoreOption

public ActionResult MoreOption()
{
...
}

So we can access this controller via http://{domainname}/Speciality/MoreOption.Now I need to access this controller in french language http://{domainname}/nos-specialites/options-supplementaires. I do not need to write an other controller class because it's the same code I use to show that page.

Was it helpful?

Solution

Actually, this is quite simple if I understand you correctly.

You just have 2 action methods, The English one and the French one that load the same model in the same controller. However, if you have 2 names for the same controller, you could achieve this with routing configuration.

routes.MapRoute(
            name: "FrenchControllerName",
            url: "Home/{controller}/{action}/{id}",
            defaults: new {area="Home",controller = "EnglishControllerName", action = "Index", id = UrlParameter.Optional }
        );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top