在asp.net应用程序中获取本地计算机的文化 [英] Get local machine's culture in asp.net application

查看:73
本文介绍了在asp.net应用程序中获取本地计算机的文化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net应用程序中,我需要了解本地计算机的文化。目前,我已将线程的区域性更改为当前用户的区域性,因此已将其覆盖。

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

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?

谢谢,
Brian

Thanks, Brian

推荐答案

默认区域性在应用程序的计算机配置中设置:

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

请参阅: http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx

此控件可以控制线程的文化-如果您不更改它们的话。因此,在更改之前,必须先读取System.Threading.Thread.CurrentThread.CurrentCulture 的值。

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


  • 重新思考您的设计以使其起作用(建议),或者/和

  • 创建一个新线程并从中吸收文化(除了性能影响)

  • 手动阅读机器配置(此处没有详细信息,因为也不是一个好的解决方案,而且超出了该答案的范围)

这篇关于在asp.net应用程序中获取本地计算机的文化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆