BrianK
BrianK

Reputation: 2705

Get local machine's culture in asp.net application

In an asp.net application, I need to get the local machine's culture. I have already changed the thread's culture to the current user's at this point so I have "written over" that.

System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentUICulture

Now I need to get what the machine is set to for logging purposes.How do I do that?

Thanks, Brian

Upvotes: 1

Views: 978

Answers (1)

user492238
user492238

Reputation: 4084

The default culture is set in the machine config of your application:

See: http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx

This controls, which culture your threads have - if you dont change them. So you have to read the value of System.Threading.Thread.CurrentThread.CurrentCulture before you alter it.

If for some reasons this is not possible, you may consider

  • rethinking your design to make it work (recommended), or/and
  • create a new thread and take the culture from that (performance implications aside)
  • read the machine config manually (no details here, because also not a good solution and out of scope of that answer)

Upvotes: 1

Related Questions