2006-12-04

Changing Locale of the ASPNET account

I have a server that has been installed using default language/locale "en-US".

This becomes a problem with the date format, which is "MM/dd/yyyy" in en-US, while in Norway where I live we use (nb-NO) "dd.MM.yyyy".

There is also a problem with which character to use as a decimal point and which to use as a thousand marker/separator:
Norwegian (nb-NO): decimal point is comma (",") , thousand marker is space. Ex: 2 345,67
US English (en-US): decimal point is dot ("."), thousand marker is comma. Ex: 2,345.67

So I need a way to set the locale that the ASPNET account is using.

There are several ways. You can set this in the web.config file:


<system.web>
<globalization
culture="nb-NO"
uiCulture="nb-NO" />
</system.web>


You can also set it in the users session, by using the Session_Start event handler:


protected void Session_Start(object sender, EventArgs e)
{
this.Session.LCID = 1044;
}


If you want to change the default settings of the ASPNET account (and you have the guts), you could go in and change the settings in the registry.

NB! It may be risky to change settings in the registry. The author of this blog is not responsible for any damage that may be caused by doing so.

Anyway here it is, change the settings under the following key:

HKEY_USERS\S-1-5-20\Control Panel\International

Here you can see settings for number formats, date formats languages etc for the user. I have as of now NOT TESTED THIS, but the key for the ASPNET user should according to a news group be S-1-5-20.

Good luck!