Currency settings in Azure
I have a small ASP.NET MVC site that displays salary data for employees.
<td align="right">@String.Format("{0:c}", Model.Salary)</td> On my local machine, this displays fine, for example. 66,000 pounds, but when loaded into Azure, it displays with a dollar, for example. $ 66,000
When setting up, I selected Western Europe as my location, but I obviously need to do something else to display it in pounds. Any ideas?
This problem is not related to Windows Azure, but it just boils down to localization (the default culture on your computer is probably different from what it was on Windows Azure). Try changing the culture to en-GB:
public ActionResult DoSomething() { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB"); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-GB"); ... model.Salary = 66.000; return View(model) } You need to set a specific culture at the application level in web.config as shown below
<configuration> <system.web> <globalization uiCulture="en-GB" culture="en-GB" /> </system.web> </configuration> Alternatively, you can also set Application_PreRequestHandlerExecute () in the global.asax file
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); I ran into this problem while trying to use Microsoft HPC Server 2012 working roles in Azure. I needed every user who sent work to the device so that it was installed in en-GB, and not in the USA, mainly because of problems with date formatting in the client application.
My solution was to change the default NTUSER.DAT file of the user, which is the template from which all future users are created. Using this specific working role, this file was stored in D:\Users\Default User\NTUSER.DAT , although our physical servers D:\Users\Default User\NTUSER.DAT it in C.
You cannot see this file in Windows Explorer unless you go to the folder options and uncheck the Hide protected files of the operating system box and check the hidden files.
Then you can make any changes to the user registry keys, the next user to create the profile then inherits these parameters. Because Azure startup scripts run before creating local users, you can force all new users to inherit these defaults.
Here is a PowerShell script that provides Azure Worker en-GB roles, not en-US
[CmdletBinding(SupportsShouldProcess=$True)] Param( [string] $NTUserDatPath = "D:\Users\Default User\NTUSER.DAT" ) If(!(Test-Path $NTUserDatPath)){ " Write-Error $NTUserDatPath incorrect" } REG load HKLM\TempHive $NTUserDatPath $Default = "HKLM:\TempHive\Control Panel\International" Set-ItemProperty -Path $Default -Name "iCountry" -Value "44" -Force Set-ItemProperty -Path $Default -Name "Locale" -Value "00000809" -Force Set-ItemProperty -Path $Default -Name "LocaleName" -Value "en-GB" -Force Set-ItemProperty -Path $Default -Name "sCountry" -Value "United Kingdom" -Force Set-ItemProperty -Path $Default -Name "sCurrency" -Value "£" -Force Set-ItemProperty -Path $Default -Name "sLanguage" -Value "ENG" -Force Set-ItemProperty -Path $Default -Name "sLongDate" -Value "dd MMMM yyyy" -Force Set-ItemProperty -Path $Default -Name "sShortDate" -Value "dd/MM/yyyy" -Force Set-ItemProperty -Path $Default -Name "sTimeFormat" -Value "HH:mm:ss" -Force Set-ItemProperty -Path $Default -Name "sShortTime" -Value "HH:mm" -Force Set-ItemProperty -Path $Default -Name "iDate" -Value "1" -Force Set-ItemProperty -Path $Default -Name "iFirstDayOfWeek" -Value "0" -Force Set-ItemProperty -Path $Default -Name "iFirstWeekOfYear" -Value "2" -Force Set-ItemProperty -Path $Default -Name "iMeasure" -Value "0" -Force Set-ItemProperty -Path $Default -Name "iNegCurr" -Value "1" -Force Set-ItemProperty -Path $Default -Name "iPaperSize" -Value "9" -Force Set-ItemProperty -Path $Default -Name "iTime" -Value "1" -Force Set-ItemProperty -Path $Default -Name "iTLZero" -Value "1" -Force REG unload HKLM\TempHive