Get local machine's culture in asp.net application

后端 未结 1 359
误落风尘
误落风尘 2021-01-23 08:24

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

相关标签:
1条回答
  • 2021-01-23 08:30

    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)
    0 讨论(0)
提交回复
热议问题