问题基本上是整个问题。在ASP.NET中,你可以通过重写InitializeCulture方法设置页面的文化/的UICulture属性,也可以设置当前线程的属性。
Question title is basically the entire question. In ASP.NET you can set the Culture/UICulture properties of a page by overriding the InitializeCulture method, or you can set the properties of the current thread.
有什么区别?什么是两者的优势/劣势?你会使用每个选项是什么情况呢?
What are the differences? What are the advantages/disadvantages of both? What situations would you use each option?
这两种方法最终在当前线程上设置的属性。
Both approaches ultimately set the properties on the current thread.
最大的区别是,页
方法支持自动检测语言 - 他们可以从请求,确定语言(如果将值设置为自动,可选默认)。相比之下,发
方法需要一个特定的文化实例。
The biggest difference is that the Page
methods support automatic language detection - they can determine the language from the request (if you set the value to "auto", optionally with a default). By contrast, the Thread
methods require a specific culture instance.
有关Web应用程序,我只是使用页
方法,因为它们提供更多的选择和救我构建的CultureInfo 例如我自己。
For a web application, I'd just use the Page
methods, because they provide additional options and save me the (admittedly trivial) trouble of constructing a CultureInfo
instance myself.