I have a request and it has a route but there are loads of them as set up in the global.asax…one typical route is…
routes.MapRoute(
"NewStore",
"{culture}/{client}/{brand}/NewStore/{action}",
new
{
culture = UrlParameter.Optional,
client = UrlParameter.Optional,
brand = UrlParameter.Optional,
controller = "NewStore",
action = "Index"
}
);
I need to create a ddl that switches the culture on the page. So actually all I want to do is recreate the route url but change one argument. So I want to do something lhe this…
Route currentRoute = httpContext.GetCurrentRoute();
Route englishCultureRoute = currentRoute;
Route spanishRoute = currentRoute;
englishCultureRoute.RouteData.Values["culture"] = "en-en"
spanishRoute RouteData.Values["culture"] = "es-es"
@Html.SelectListForRoutes(englishCultureRoute,spanishRoute);
So the above is pseudocode, I want to do the first bit in a controller but how do I do this in c#?
you can access the route data from the controller from
if you want to assign new values you can do something like this
and in the view you can access the route data values from
but if your taking about globalizing your app there are better solutions , you can check this