go though the below links it might help you to achieve what you want to
http://adamyan.blogspot.in/2010/07/addition-to-aspnet-mvc-localization.html
http://www.codeproject.com/Articles/207602/Creating-a-Bilingual-ASP-NET-MVC-Application-Par
Vra
I have a base controller in which I get and set the CurrentThread
Culture.
protected override void ExecuteCore()
{
string cultureName = null;
// Attempt to read the culture cookie from Request
HttpCookie cultureCookie = Request.Cookies["_culture"];
if (cultureCookie != null)
cultureName = cultureCookie.Value;
else
cultureName = Request.UserLanguages[0]; // obtain it from HTTP header AcceptLanguages
// Validate culture name
cultureName = CultureHelper.GetImplementedCulture(cultureName); // This is safe
// Modify current thread's cultures
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
base.ExecuteCore();
}
Everything works fine. But now I realized that regarding SEO I will have some issues since probably not all my languages will be picked up.
So I thought about putting the CurrentCulture
on the url :
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "SpecificCulture",
url: "{culture}/{controller}/{action}/{id}",
defaults: new
{
controller = "Home",
action = "Index",
culture = Helpers.CultureHelper.GetCurrentNeutralCulture(),
id = UrlParameter.Optional
}
);
}
However this doesn't work since my RegisterRoutes
runs before my BaseController
which means that the url does not refect the current selected culture, it does reflect the default culture.
So my question is : Is there anyway to update my routing maps after my culture is set?
Thanks
Oplossing
go though the below links it might help you to achieve what you want to
http://adamyan.blogspot.in/2010/07/addition-to-aspnet-mvc-localization.html
http://www.codeproject.com/Articles/207602/Creating-a-Bilingual-ASP-NET-MVC-Application-Par