Question

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?

Was it helpful?

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.

OTHER TIPS

adding in your web.config this is totally legit if you want your site to run always in this culture:

<system.web>
....
<globalization culture="en-US" uiCulture="en-US"  enableClientBasedCulture="false"  />

it is the same as set in you code DefaultThreadCurrentCulture.

Anyway I can bet that:

or in your server's machine.config culture is set as "en-CA"

or your calendar control (probably a javascript one) is loading the clientculture. You can check this looking at your browser default language settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top