I have a site with multi-language features. I'm still using cookie to detect the language so for example if user choose "English", then I will change the cookie value to "EN" and serve "english page" to user.
I want to change this behavior and read the language from URL instead of cookie. So for example if the current url for product page is
www.ezstore.com/product/asus-gtx970
I want to change the url to
www.ezstore.com/en/product/asus-gtx970 for english
www.ezstore.com/fr/product/asus-gtx970 for french
I was thinking of changing the RouteConfig
and read the URL to get the language value. Is this possible?
My current RouteConfig
is :
routes.MapRoute("Product", "Product/{id}", new {
controller = "Product",
action = "Index",
id = UrlParameter.Optional
});
routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional
});