Culture. What am I doing wrong?

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am initializing the culture of a page as follows:

protected override void InitializeCulture() {
base.InitializeCulture();
CultureInfo culture = Profile.Get().Visitor.Culture;
if (culture == null) culture = default(CultureInfo);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}

Basically, my objective is to get the culture from Visitor property in
profile. If it is null then use the default culture in Web.Config:

<globalization
culture="auto:pt-PT"
uiCulture="auto:pt-PT"/>

The problem is that when the culture is null in profile I always get
"en-US".

What am I doing wrong?

Thanks,

Miguel
 
Hi Miguel,

Your problem is default( CultureInfo ) which gives null. You should use new
CultureInfo("pt-PT"); or better yet:

culture = CultureInfo.CurrentCulture;

+++ Rick ---
 
Back
Top