Possible implementation of localization of Msdn style URL

I am trying to come up with how to implement msdn as address bar based localization

http://msdn.microsoft.com/en-us/library/system.string.aspx http://msdn.microsoft.com/ru-ru/library/system.string.aspx 

I tried to find various information about ASP.NET localization, but could not find a description of the strategy that could be used to achieve the result.

I am not very familiar with ASP.NET and would like to get some tips on how to implement something that will lead to similar paths on my site (using the best way with the least code duplication, for example).

I understand that I could duplicate both files in two folders. or 10 files in 10 folders if I received 10 cultures. But this is not the best strategy. Do rewriting and skipping parameters take place or?

Update: I completed its implementation as follows: for my localized pages, I register routes to all current cultures (in the general method), for example, for help.aspx I register routes ru-ru/help/ and en-us/help/ , inside help.aspx (and other localized pages, oop way). I parse the address bar and extract the desired language. After that, I set the html content appropriate for the culture specified in the url.

+4
source share
2 answers

Microsoft seems to be rewriting URLs or using custom routing in ASP.NET. They use URLs to determine which culture to choose. They could use a query string, but the URLs would not look so good.

I would suggest starting with ASP.NET MVC as it uses out-of-box routing. Then change the routes to match those used by MS above before using them to apply the culture.

Where you will place your application can affect whether you can do such things. If you manage the entire server and do not use shared hosting, it will be easier to implement these things, especially URL rewriting. If you need to use ASP.NET 2.0 because you are in some kind of old corporate environment, you will probably have an even harder time.

+3
source

Valentine, try using URL routing:

1 - add routing information to global.asax

 void Application_Start(object sender, EventArgs e) { RouteTable.Routes.MapPageRoute("cultureCrossroad", "{culture}/Library/{article}", "~/library/ArticleHost.aspx"); } 

2 - Create a homepage in ~ / Library / ArticleHost.aspx

 public partial class ArticleHost : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // ! Here we have access to url parts and can redirect user for desired page via Server.Transfer method. var response = string.Format("culture: {0}<br/> article: {1}", Page.RouteData.Values["culture"], Page.RouteData.Values["article"]); Response.Write(response); } } 
0
source

All Articles