c# - ASP MVC 2 Change language by url -


I am trying to make a website voice with 2 or more languages ​​for one language.

When I follow the default route (administrator / action) Html.ActionLink ("NL", ViewContext.RouteData.Values ​​["action"]. ToString (), New {language = "Nl-NL"}, blank) This works but when the action is called by the action from the parameter, it (logically) only creates a link with the controller as well as the current action parameters Is ignored

My current route:

  routes MapRoute ("ProjectCategory", "{language} / Projects / {action} / {slug}", new {controller = "projects", verb = "extension", slug = string. Empty, language = "en-US"} ); The link created with  html :  
  http: // localhost / mysite / nl-nl / projects /   

extension /

How to solve this problem?

  HttpContext.Current.Request.Path.Replace ("/ en-US /", "/ Nl-nl /")   

This is not the most beautiful way, but works for me. (Of course you should replace en-US with the current code)

Comments