I'm currently developping a globalized ASP.NET application (needs to work in english and french).
My problem is, the french culture in Windows as been modified (number and currency decimal separator has been set to "." instead of "," wich is de default) and I need it to have the default values. To make a long story short, this is messing with decimal.TryParse()
function and I don't want to patch it with code (the problem is a setup one, so I need to fix the setup, not the code).
So I went to the Windows control panel, reseted the culture default value (number/currency decimal separator went back from "." to ","), and expected the change to take effect in my web application. Nope, didn't work.
Well, maybe it needs a good old iisreset
to take effect. Did it, test again... Nope, same error.
OK OK that migth be pretty deep, so why not just reboot the machine. Reboot, retest, and... Nope, the ... decimal separator is still ".".
That frustating... let's see what a plain simple console application will do. In a console it work like a charm. It's always the same as Windows settings.
Could it be that the culture definitions for ASP.NET are defined at installation and cannot be changed after? Tried an aspnet-regiis -i
just to be sure and guess what? Didn't work!
So, can anyone tell me how ASP.NET manages it's culture definitions and how I can get it to update them?
Thanks in advance!
Starting with this configuration on my computer (just showing the decimal separator, but I'm changing both decimal and currency separator):
I get this in ASP.NET application Debug:
And this in a plain console application:
And then I change the Windows config to this:
Wich gets me this in ASP.NET Debug (after iisreset
, reboot, etc.):
And the correct settings in the console application:
A collegue of mine pointed out that localization informations are kept under some registry keys:
HKEY_USERS\.DEFAULT\Control Panel\International
HKEY_USERS\S-1-5-20\Control Panel\International
Wich led us to think that if localization is user defined, and IIS runs with the DefaultAppPool user, changing my user localization settings won't have any effect.
Windows offers the possibility to refresh localization settings for system accounts and new users:
Checking the two checkboxes seems to reset evething BUT the DefaultAppPool settings.
Based on the second update on registry informations, we took the easy way out: copy the default localization settings from default to those used by the DefaultAppPool user.
So:
Export
HKEY_USERS\.DEFAULT\Control Panel\International
Export (for backup -> IMPORTANT!!, if things go wrong, you'll need it)
HKEY_USERS\S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415\Control Panel\International
Where S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415
is the key used by the DefaultAppPool user
Modify the first exported key path to be the same as the second
Even if this definitly solved the problem, there might be a better solution and I'd still love to ear from it.