views:

22

answers:

1

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?

A: 

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.

Jeff Sternal
Brilliant, that makes sense. One quick followup though.. how is the language detected from the request?
Liggi
It accesses it through [HttpRequest.UserLanguages](http://msdn.microsoft.com/en-us/library/system.web.httprequest.userlanguages.aspx), which parses the request's HTTP headers. (I *think* the `Accept-Language` header, maybe `Content-Language`.)
Jeff Sternal