How do I change the Localization settings for domain accounts being used by IIS Application Pools

325 Views Asked by At

A few facts about the scenario

  • 3 FWE (Front End Web) servers
  • 2 DC (Primary/Secondary) servers
  • at the time the accounts were created localization was en-US on all servers
  • since then all servers have been changed to use en-AU localization
  • the accounts are being used by IIS Application Pools (Integrated Mode) configured on each FWE
  • when ASP.Net runtime is executing it is definitely using the correct service account
  • the service accounts do not have 'logon as user' privileges in AD

The problem is that the currently running thread still has Culture and UICulture reported as en-US!

Am I incorrectly assuming that the application pool will load localization settings for the service account from domain?

We don't want to set elements explicitly on each FWE

Any suggestions welcome!

1

There are 1 best solutions below

1
On

You are going to need this set this some how. The local settings from the app pool identity is not taken into account.

One approach is have the culture based on the browsers' header info. A browser broad casts what culture the user prefers.

see the link below: Auto-detecting and setting the Culture with Code

http://weblog.west-wind.com/posts/2014/Mar/27/Auto-Selecting-Cultures-for-Localization-in-ASPNET

The simplest implementation:

if (HttpContext.Current != null && HttpContext.Current.Request.UserLanguages != null)
{
    culture = Request.UserLanguages[0];     
}
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture); // de-DE
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); 

Request.UserLanguages holds the browser settings: a list of cultures in prefeered order. You would need to handle sorting through this and deciding what to do when this is not one of your en-US / en-AU.

The article details more detailed handling and other concerns.

Alternatively, you may be able to dig through System.AppDomain.CurrentDomain to see if the app pool user/ it's culture is present in that object.

Best of luck! Brian