Server Side ASP.NET

I have an application that runs on an Anglo-American ASP.NET server (English installation of a Windows server and .NET Framework). I set the globalization options to:

<globalization culture="auto" uiCulture="auto" responseEncoding="utf-8"/>

which is great for most applications. However, I have to deal with money transactions in this application, and I need to provide numbers in the format of 0.00 (not 0.00). Most of our users use an application from a culture that uses 0.00.

I found out that even when using Decimal.ToString("0.00")decimals, they still printed as 0.00 in French browsers.

What is the correct way to solve this problem? Do I have to change the current culture for a function where I need to deal with numbers in order to set it to EN-US at the moment? Will I always get the correct format if I use Decimal.ToString("0.00", NumberFormatInfo.InvariantInfo)?

Thanks!

+3
source share
2 answers

You can change most of the culture information by setting it. The specific setting you want:

Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = "."
+2
source

Changing the culture on each variable is too painful. Try using information about the theme culture. Sort of:

CultureInfo MyCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentCulture = MyCulture;

You can set this configuration to global.asax at user login or at the home page level.

The best

+1
source

Source: https://habr.com/ru/post/1712035/


All Articles