.NET Globalization: Set Culture/UICulture on a Page or a Thread? What's the difference?

二次信任 提交于 2019-12-11 12:51:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!