开发者

Azure virtual paths for localization

开发者 https://www.devze.com 2023-01-12 08:36 出处:网络
I would like to provide localizatio开发者_JS百科n for my website in Azure. I went with a classic aspx website since localization is supported by classic asp out-of-the-box and I have only a few pages.

I would like to provide localizatio开发者_JS百科n for my website in Azure. I went with a classic aspx website since localization is supported by classic asp out-of-the-box and I have only a few pages. I want to keep it simple so MVC might be overkill.

I plan to register only 1 Azure web role for the site (foo.com) but would like virtual paths for localization, eg. foo.com/de-de, etc. Azure does not allow virtual folders like IIS, so I think I can use Request.Path and do some jugglery to detect the virtual (localized) path.

Can you think of any other clean method? Maybe some web.config tags?

Thanks


Maybe you can do something with ASP.NET routing?


yes, sorry I did not see your response earlier and that's exactly what I used. I was not aware that we can use routing in web forms: http://msdn.microsoft.com/en-us/library/cc668177.aspx

I defined my localization pattern in the RegisterRoutes, like:
routes.MapPageRoute("loc", "{language}-{country}/{action}", "~/default.aspx", true)

Rather than page load, I use the InitializeCulture() event and set the thread culture based on the values as derived from the route spec., e.g. string lang = Page.RouteData.Values["lang"].ToString(); Remember to check for nulls, etc. Think of putting this in a base Page class of yours.

0

精彩评论

暂无评论...
验证码 换一张
取 消