Search code examples
c#asp.netglobalizationcultureinfo

ASP.NET Application has incorrect CurrentCulture - en-CA instead of en-US


I have an ASP.NET Application that I migrated to a new server. I made an effort to, as closely as possible, duplicate the old web servers settings.

However, the application is now throwing up datetime.tryparse exceptions on our calendar controls.

The UICulture is set to en-US

The TryParse() methods are specifying en-US explicitly

The Culture seems to be defaulting itself to en-CA.

The IIS web configs haven't changed (they are default) and the server's language settings are set to en-US.

Is there a place I am failing to check for a culture setting? I had a look at this stack thread but nothing immediately jumped out at me.

Is forcing a culture via the web config the only resolution here? Surely I must have failed to check a spot for an accidental setting of en-CA?


Solution

  • I ran into similar issues with our environment where our server machine was running Windows Server 2008 R2 and after struggling we managed to figure out where the Current Thread was reading the culture from.

    If you navigate in the registry to the following path

    HKEY_USERS\.DEFAULT\Control Panel\International
    

    You will see that it is probably set to something that you do not want. If for example you would like to change it to "en-CA" you will need to change the current registry values to the following:

    Locale: 00001009
    LocaleName: en-CA
    sCountry: Canada
    sLongDate: MMMM-dd-yy
    sShortDate: dd/MM/yyyy
    sYearMonth: MMMM, yyyy
    

    Once these registry values have been changed, the machine will require a reboot.

    Hope this helps you as much as it helped us in solving our problem.