After migrating to Windows server 2012 R2 / .NET 4.5, decimal sign is "," instead of "." RRS feed

  • Question

  • User1318813957 posted

    Hello together

    Our current web application is running on windows server 2008 (R2 I guess) w. .NET CRL 4.5 installed and project target 3.5.
    We set up a new server with Windows Server 2012 R2, .NET CLR 4.5 and project target 4.5.

    The globalization setting is read from the users system/browser language so this should be the same in both applications on the same test system/browser (DE [-CH]).

    Now the problem is that all numbers that were formated as xxx.xx in the previous environment now are formated as xxx,xx which leads to some trouble.
    It seems that the decimal sign has changed from "." to "," with the same locale (?) on the same test system/browser.

    Any ideas or suggestions what could be the problem and how to fix this?

    P.S. I found out that on the old environment, culture was set to "Invariant Language ..." (culture="") whilest it is "Detect automatically" (culture="auto") on the new environment.
    Maybe it's best to change this back as it isn't actually used "directly" in our application?

    Unfortunately, this doesn't seem to impress the ",". It's still showing "," instead of "." :(
    Anybody an idea how to change this behaviour?

    Thank you very much!

    Thursday, April 23, 2015 11:30 AM

All replies

  • User1318813957 posted

    Found out that both applications are running with "de-ch". Using dots on the old machine and commas on the new machine for decimal separation.

    nice thing! Yell
    any ideas how to change this?

    Friday, April 24, 2015 6:27 AM
  • User1318813957 posted

    Found out that this has changed from Win 7 and earlier to Win 8 (or apparently Server 2012): http://www.sadev.co.za/content/windows-8-and-how-it-breaks-applications-south-africa

    Unfortunately, I wasn't able to find a solution which makes me happy. I'd like a one-time setup which doesn't change the culture itself. So setting the culture to "en" in web.config (""=invariant culture seems to be overwritten by the framework with the user's settings) or change the culture to invariant in global.asax isn't what I want.

    The best solution I found until now is doing the following in the Application_PostAcquireRequestState handler on every request (Application_Start is too early, unfortunately):

    Dim CurrentCulture As Globalization.CultureInfo = Threading.Thread.CurrentThread.CurrentCulture.Clone
    CurrentCulture.NumberFormat = Globalization.NumberFormatInfo.InvariantInfo
    Threading.Thread.CurrentThread.CurrentCulture = CurrentCulture

    Friday, April 24, 2015 7:32 AM