Request.UserLanguages

C

Chad

My app is blowing up when it attempts to retreive the local language
settings of the user accessing the site.
 
C

Chad

Sorry. I prematurely posted.

Anyway, my code returns an "Object Reference not set to an instance of an
object"
when it executes the following line of code:

Dim BrowserCulture As String = Request.UserLanguages(0)

I asked the user experiencing the problem to check his local regional
settings. He told me everything was set to English-US. (Regional and
language settings-->Languages

We are using Windows XP Professional.

Any thoughts?
Thank You
 
J

Joerg Jooss

Chad said:
Sorry. I prematurely posted.

Anyway, my code returns an "Object Reference not set to an instance
of an object" when it executes the following line of code:

Dim BrowserCulture As String = Request.UserLanguages(0)

I asked the user experiencing the problem to check his local regional
settings. He told me everything was set to English-US. (Regional and
language settings-->Languages

We are using Windows XP Professional.

Any thoughts?
Thank You

Maybe the HTTP header gets lost on its way, although that really should
not happen. You can use a debugging proxy like Fiddler
(www.fiddlertool.com) to monitor the HTTP traffic and see what happens
to the Accept-Language header.

Cheers,
 
J

Juan T. Llibre

Request.UserLanguages returns an array.

Split it into its segments

int count;
String[] userLang = Request.UserLanguages;

for (count = 0; count < userLang.Length; count++)
{
Response.Write("User Language " + count +": " + userLang[count] + "<br>");
}
 
J

Juan T. Llibre

Request.UserLanguages returns an array.
You need to split it into its segments.

If you are using VB.NET :

Dim userLang() As String
Dim count As Integer

userLang = Request.UserLanguages
For count = 0 To userLang.GetUpperBound(0)
Response.Write("User Language: " & Cstr(userLang(count)) & "<br>")
Next count
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top