Option 1
In an ASP.NET page (ASPX) you need to override the InitializeCulture method:
protected override void InitializeCulture()
{
this.UICulture = "";
this.Culture = "";
}
Option 2
In a page's markup:
<%@ Page UICulture="" Culture=""
Option 3
In web.config
<globalization culture="" uiCulture="" enableClientBasedCulture="true" />
Option 4
Using an HttpModule (This sample uses ASP.NET profiles to get the language, you can change to get the language from a different source)
public class LocalizationModule : IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += context_PreRequestHandlerExecute;
}
void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
var application = sender as HttpApplication;
var context = application.Context;
var handler = context.Handler;
var profile = context.Profile as CustomProfile;
if (handler != null)
{
var page = handler as Page;
if (page != null)
{
if (profile != null)
{
if (!string.IsNullOrEmpty(profile.Language))
{
page.UICulture = profile.Language;
page.Culture = profile.Language;
}
}
}
}
}
}
Then you just need to configure it on the web.config file:
<httpModules>
<add name="Localization" type="Msts.Topics.Chapter06___Globalization_and_Accessibility.Lesson01___Globalization_and_Localization.LocalizationModule" />
</httpModules>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="Localization" type="Msts.Topics.Chapter06___Globalization_and_Accessibility.Lesson01___Globalization_and_Localization.LocalizationModule" />
</modules>
</system.webServer>