Culture. What am I doing wrong?

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
 
R

rstrahl

Hi Miguel,

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

culture = CultureInfo.CurrentCulture;

+++ Rick ---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top