问题
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?
回答1:
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.
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.
来源:https://stackoverflow.com/questions/3933345/net-globalization-set-culture-uiculture-on-a-page-or-a-thread-whats-the-diff