Say I have a ASP.Net MVC 4 web application. In this app I have 2 controllers "Product" and "Support".
This app is a language-aware web app, so when a user navigates to http://server/product/index, I'd like to automatically redirect to http://server/en-us/product/index
Same thing for support: From http://server/support/ to http://server/en-us/support/
I already have some logic to determine the user's language based on the browser, I'm just not sure the best way to achieve that thing explained above.
Just to clarify, I already a default route with language
private const string languagePartPattern = @"(\w{2})|(\w{2}-\w{2,4})";
routes.MapRoute(
name: "DefaultLang",
url: "{lang}/{controller}/{action}/{id}",
constraints: new { lang = languagePartPattern }, //For example: en or en-US
defaults: new { lang = SettingsHelper.DefaultLanguage, controller = "EntryPoint", action = "Index", id = UrlParameter.Optional }
);
If I navigate to http://server/product/, it does not automatically redirect to http://server/en-us/product/. However, it works fine if I navigate to http://server/en-us/product/ directly