0

I my .Net application I use CurrentCulture to format dateTime and numbers. When on the Localhost this works like a charm and the format changes when I change the system's culture. When I publish my application though it does not. As a test I added alert("@System.Globalization.CultureInfo.CurrentCulture.DisplayName as a test and no matter to which culture I change my system this stays Swedish(Sweden). I added ClearCashedData for the current culture, which again works on the localhost, but not for the published site.

I guess I have a two part question: 1. where does the published application get it's culture from and 2. how can I make it so that it gets it's culture from my (or the user's) system?

Thanks!

user6386826
  • 131
  • 1
  • 1
  • 10

1 Answers1

0

You are using the CultureInfo of the host machine.

To get the user's one look at the following From MSDN:

You can also use the CultureInfo.CurrentCulture property along with the HttpRequest.UserLanguages property to set the CurrentCulture property of an ASP.NET application to the user's preferred culture, as the following example illustrates. CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

Ofir Winegarten
  • 9,215
  • 2
  • 21
  • 27
  • I have thought of that, but then you're stuck with the language that is chosen as the Display Language, aren't you, and not the language that you choose under Region and Language - Format. And it is that one I wan/need to use. – user6386826 Mar 03 '17 at 16:21