views:

396

answers:

2

Is it possible that .NET uses on server A ',' as decimal seperator and on another server B '.'? + How can you detect this?

When converting strings to doubles, on server A everything works fine, but on server B we have problems.

Example:

server A : 20,4 --> 20.4 server B : 20,4 --> 204

We would need to detect this so that on both servers things keep on working.

thx, Lieven Cardoen

+1  A: 

Sounds like the locale is being set correctly on one server but not the other.

There are a few ways you could do this, but you might want to set the locale for the current thread in your App/ASP.NET page using Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture.

To set this for the entire application, you'd do this in your web.config:

<configuration>
  <system.web>
    <globalization culture="en-US" uiCulture="en-US" />
...
Eric Petroelje
Can you set this for the overall asp.net application instead of for each thread separately?
Lieven Cardoen
Yup! Updated my answer.
Eric Petroelje
I guess in your case it might be either "nl-BE" or "fr-BE", but you get the idea.
Eric Petroelje
+1  A: 

I use

String.Format(System.Globalization.CultureInfo.InvariantCulture, ....)

in those cases where you do not want to have culture specific output. (For example, when you write serialize data for other applications etc.) This way no matter what Culture is currently set, the output will always be the same.

f3lix