I have a question. I read a post here on how to change the language by sending a parameter to the controller, and the controller can handle this change.
here is what i read:
First: add a route
routes.MapRoute( "Default", "{language}/{controller}/{action}/{id}", new { language = "en", controller = "Home", action = "Index", id = "" } );
Second: use ActionLink to send the parameter
<li><%= Html.ActionLink( "Spanish", ViewContext.RouteData.Values["action"].ToString(), new { language = "es" })%></li> <li><%= Html.ActionLink( "French", ViewContext.RouteData.Values["action"].ToString(), new { language = "fr" })%></li> <li><%= Html.ActionLink( "English", ViewContext.RouteData.Values["action"].ToString(), new { language = "en" })%></li>
Now I tried this solution and it works fine. However, it only works once. I mean, if you click on French, it will display the page in French. But the rest of the links on the page still point to the default value of "en".
How do I change the default “language” to the selected language so that all links use the selected new language?
source share