I have the following code in my Global.asax file:

Protected Sub Application_PreRequestHandlerExecute(sender As Object, e As System.EventArgs)
    System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo(ConfigurationManager.AppSettings("Language"))
    System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(ConfigurationManager.AppSettings("Language"))
End Sub

This sets the UICulture and Culture to a value defined in the web.config AppSettings.

This therefore changes date formatting text throughout the application.

However, my application has a subfolder, /Admin. If the culture is set to es (Spanish), then I still need the admin folder to be en (English).

How is this possible?

有帮助吗?

解决方案

One solution I've thought of (but I'm not sure it's the best, so open to other ideas), is to override the Culture and UICulture in my Admin sections MasterPage, which every web form calls from:

Sub Page_Init()
    System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en")
    System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en")
End Sub
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top