ASP.NET user's locale question

  • Thread starter Thread starter Jon Wang
  • Start date Start date
J

Jon Wang

where do you store the information about the user's locale?

I got the answer online saying that it's System.UI.Page.Culture. But I
think it should be Thread.CurrentThread.CurrentCulture and
Thread.CurrentThread.CurrentUICulture. Could you please let me know which
answer is right?
 
Thread.CurrentThread.CurrentCulture and
Thread.CurrentThread.CurrentUICulture

AS far as I know Page.Culture doesn't even exist, and even if it did you
typically want the culture set thread-wide, so that business logic will also
run in the specified culture.

Karl
 
because of asp.nets thread agility, you have to be very carefull with
setting the culture of a thread in asp.net. normally a webrequest is not
serviced by the same thread for all of the page processing calls (events).
i.e., if you set the thread culture on the pageload event, you are not
guaranteed the same culture setting will be in effect during the on a click
event for the same page request.

before calling any routines that need culture set - you should set the
culture, call the routine, then restore the culture to your default. this
will prevent the culture getting changed when you do not expect it.

-- bruce (sqlwork.com)
 
Back
Top