Basically in my RouteConfig.cs I am trying to map a route that varies based on the current language of the browser.
What I'm trying to get to is a dynamic path like:
/books-with-description/
/libros-con-descripcion/
these strings are constants (they are not stored in the db) and there are only two (Spanish and English)
Try with:
routes.MapRoute(
name: "Libros",
url: "{index}/index/{lang}",
defaults: new { controller = "Libros", action = "Get", lang = UrlParameter.Optional, index = @Rurl.LibrosConDescripcion }
);
And I also tried:
routes.MapRoute(
name: "Libros",
url: @Rurl.LibrosConDescripcion + "/index/{lang}",
defaults: new { controller = "Libros", action = "Get", lang = UrlParameter.Optional}
);
Being @Rurl.LibrosConDescripcion the access to the string in the resources file
For some reason, in this case, the language change that I set in CurrentThread.CurrentCulture is not taking me. I guess it's because the application startup runs in its own Thread and starts only once, regardless of the Threads created by each client browser request (Correct me if I'm wrong).
Suggestions? I have no choice but to generate that part of the URL from an ActionLink in Razor?
(The idea was to set it only once and not have to do it for each view that wants to access that url)