4

In a number of places in my code I'm converting values into currency using the ToString c method: .ToString("c")

On my dev machine this correctly formats values in line with my regional settings and as a result the currency displays as such: £100.00

However on the production server it is ignoring the windows regional settings and instead defaulting to a US based setting:

$100.00

I had a similar problem with DateTimes but converted to the ISO 8601 format.

Where is the production server is picking this up from?

Chris Nevill
  • 5,922
  • 11
  • 44
  • 79
  • Are your dev machine's and prod server's regional setting same? Check out from `Regional Settings -> Formats -> Additional settings -> Currency -> Currency symbol` – Soner Gönül Sep 28 '13 at 21:43
  • They are yes. Both are setup to English (United Kingdom), £ for currency, DD/MM/YYYY etc – Chris Nevill Sep 28 '13 at 21:47
  • Check also [`NumberFormatInfo.CurrencySymbol`](http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencysymbol.aspx) on both machine. – Soner Gönül Sep 28 '13 at 21:48

3 Answers3

3

Set proper culture in your web.config file:

<globalization uiCulture="en-GB" culture="en-GB" />

Check this article out: http://msdn.microsoft.com/en-uS/library/bz9tc508.aspx

Olexander Ivanitskyi
  • 2,202
  • 17
  • 32
0

You can force Culture in your ToString function

number.ToString("c", new CultureInfo("en-GB"))
Jernej Novak
  • 3,165
  • 1
  • 33
  • 43
0

I tried all the other solutions mentioned here but kept running into the same issue noted in the original question.

In the end, my problem was resolved by changing who the app pool was running as in IIS. When set to LocalSystem, the US $ would always show for currency, regardless of what I set my region to or how I modified my web.config files.

When I changed the app pool to run as any other interactive user on my machine, then it immediately began reflecting the region settings.

Steve Scheffler
  • 3,706
  • 2
  • 21
  • 22