Different culture settings between IIS and ASP.NET’s Development Server

August 5, 2010

11 comments

A few years ago I’ve stumbled on a very annoying scenario on my machine: I had used ASP.NET’s development server (the web server that pops up when debugging web applications in Visual Studio) while developing a web application and when I moved my web application to my local IIS, suddenly the culture of the thread changed from my local culture (he-IL) to a Greek culture (el-GR).

This was a few years ago, and took some time to solve, and I though I had the unfortunate luck of being the owner of a weird installation of Windows 2003 server, but in the last 24 hours I’ve encountered three different computers that had a similar problem, where some of them decided that IIS should run on an English culture (en-US) and some on a French culture (fr-CH).

First of all, the reason IIS runs on a different culture than the ASP.NET’s development server is that the ASP.NET’s development server runs under the account of the user that is currently logged in, while IIS’s application pools runs under a different account:

  • For Windows XP with IIS 5.1, the user is ASPNET (a local account created by the .NET Framework)
  • For Windows 2003 and on (Vista, 7, 2008 server) with IIS 6 or 7.X, the user is Network Service (unless specified otherwise in the application pool configuration).

The reason why the Network Service account uses a different culture can usually be traced back to the installation of the operating system. The culture of newly created accounts is decided according to the regional settings of the default user, and the Network Service account is set when the operating system is installed. So if you install your windows with the English – United States settings which is usually the default culture, the account will use the en-US culture. In my case, someone probably missed the Hebrew option and selected Greek by mistake.

To fix this problem, you’ll need to change the regional settings of these special accounts (network service, local service, aspnet etc…). Fixing this depends on your operating system:

  1. For Windows Vista and on (7, 2008 server) this is quite easy, just follow the steps specified in the following link.
  2. For Windows 2003 and XP, you’ll need to edit the registry manually:
    1. Open the registry, and export the “CURRENT_USER\Control Panel\International” branch. This branch contains the regional settings of the current user.
    2. Under the HKEY_USERS hive, for each SID (security identifier) and for the .DEFAULT user perform the following steps:
      1. Edit the exported registry file and set the path of the two sections to the account you want to fix. For example, to fix the network service account, change the “HKEY_CURRENT_USER\Control Panel\International” branch to “HKEY_USERS\S-1-5-20\Control Panel\International”.
      2. Double-click the reg file to import it to the registry.
      3. Return to the registry editor and check that the International branch was updated successfully for the account.

If you want to see which SID belongs to which builtin account, you can look at the following list.

After updating the settings you might want to restart your machine, or at the least recycle your application pool (or for IIS 5.1, kill the aspnet_wp process).

Hope this helps someone.

Additional: The scenario I wrote about describes a system that depends on the culture of the account that runs the application pool process. If you build a web application and you want it to use a specific culture, don’t become dependant on the culture of a specific account, instead use the <system.web>\<globalization> section and set the culture attribute to define the specific culture you want to use in the application. This way you can deploy your application to any server, without having to worry about mismatching server configuration.

Add comment
facebook linkedin twitter email

Leave a Reply to Thomas Cancel Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

11 comments

  1. RameshkumarNovember 9, 2010 ב 6:06 am

    Hi,

    I have face different culture problem in my application. For example, I have configured my application in IIS7 and set the language chines in browser. The chines culture is set When run the application in server. I will go to change language german in my local browser. I will see my application in local browser which culture in applied.

    how to set different culture in IIS7?

    Reply
  2. ThomasJune 1, 2011 ב 9:40 am

    Thanks, great tip!

    Reply
  3. BenDecember 12, 2011 ב 6:06 pm

    Thank you! Just what I was looking for!

    Reply
  4. MihaiApril 5, 2012 ב 1:39 pm

    I have an issue with populating a DateTime field in a DataSet running in IIS and I’ve thought it’s related to the regional settings, but it’s not. They are fine. Even weird – it only happens sometimes.
    Any ideea?

    Reply
  5. ZekeDecember 19, 2012 ב 1:50 am

    Thanks, very helpful.

    Reply
  6. Narciso MazivilaFebruary 18, 2013 ב 4:26 am

    Thanks a lot, was very helpful

    Reply