Where is System.Threading.Thread.CurrentThread.CurrentCulture set? I have a US customer (and I am in US); the debugging code shows the value equals "en-GB". And therefore dates are shown in British format ('DD/MM/YYYY'). Where is this set, in which file?
-
1Is this on a web page? It should be set by the user-agent (aka, the browser) – Flydog57 Aug 11 '20 at 23:24
-
Whatever @Flydog57 said... except "**could** be set by the user-agent". Obviously without knowing at least what you are debugging (based on "asp.net" tag it could be a web site, but many questions tagged as "asp.net" with intention "written in C#") and how whatever code is configured... – Alexei Levenkov Aug 11 '20 at 23:40
-
Yeah, **_could_** be set. If you have access to the logs, I'm pretty sure you should see the user-agent string there (sorry, it's been a log time since I waded through logs like that) – Flydog57 Aug 11 '20 at 23:42
-
Most likely, it's set on the client machine's OS; if it's Windows 10, ask your client,if possible, to run `Get-Culture` command in PowerShell - chances are, it's *en-GB* – CoolBots Aug 11 '20 at 23:52
-
This is a ASP.NET application; web site. The app is running on a Server 2016. I see this setting when I connect to the server via Remote Desktop. And one of the clients see it in her browser. I have a setting in my program that uses CODE when calling SQL Select (SQL Server). And the code depends on the culture. It is "103" for 'en-GB' and '111' for 'en-US'. This works well on my PC and on other customers. I will follow all your suggestions. Thank you all. – Hidalgo Aug 12 '20 at 00:03
-
1You can force by https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentuiculture?view=netstandard-2.0 and https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentculture?view=netstandard-2.0 – Aug 12 '20 at 04:12
-
@donggas90 Thank you very much. Your link helped to force the culture to the US. I don't know how to give you the solution though. Let me know, please. – Hidalgo Aug 12 '20 at 19:25
-
1I posted answer with more informations. If you solved the issue, please mark the answer. – Aug 12 '20 at 20:11
-
Does this answer your question? [CurrentCulture incorrectly defaulting to en-US in ASP.net](https://stackoverflow.com/questions/11135002/currentculture-incorrectly-defaulting-to-en-us-in-asp-net) – Lance U. Matthews Aug 12 '20 at 20:16
2 Answers
You can force current CultureInfo
s by CultureInfo.CurrentUICulture and CultureInfo.CurrentCulture.
The first one effects to text based things such like datetime etc. The second one effects to numbers such like floating points. Setting both to same CultureInfo
is basic implement.
Note that, this will work fine if you don't consider multi-languages. Or you need to add language selecting menus.
Generally, CultureInfo
comes from the OS (presuming it's not explicitly overridden in code); in case of a web application, CultureInfo
typically comes from the client OS, via HTTP's Accept-Language
header (you can likely monitor this with tools like Fiddler, etc).
In your case, if it's possible to ask the client to check their system setting - on Windows 10, the PowerShell command Get-Culture
will return the current culture set in the OS, for instance - you might be able to determine the source of the problem.
Furthermore, it is possible to set a different culture for the current user (no Admin required, I believe), using the PowerShell Set-Culture -CultureInfo en-US
command, where en-US is the desired culture (no pun intended). There is also a way to reset it for the entire machine, with the PowerShell Set-WinSystemLocale -SystemLocale en-US
command (Admin rights and a reboot are required).

- 4,770
- 2
- 16
- 30
-
-
1The system accessing your ASP.NET application is Server 2016? Your server is very likely set to `en-US`, but is not really relevant for determining client-side culture in a typical web app setup. Either way, same PowerShell commands should work on Server 2016, if you want to check; be careful with any `Set` commands though. – CoolBots Aug 12 '20 at 00:13