Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4601680
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:51:46+00:00 2026-05-21T23:51:46+00:00

It seems that I have problem changing System.Globalization.CultureInfo.CurrentUICulture value according to the user preferences

  • 0

It seems that I have problem changing System.Globalization.CultureInfo.CurrentUICulture value according to the user preferences (.NET 4.0 web application).

In my web application, I have two buttons. One for the Greek Language and one for the English language. When the buttons are clicked, a request goes to the server asking to change the user preferred language. For Greek, I send “el-GR” and for English, I send “en-US”.

On the server side, I use the following piece of code to change the current CultureInfo.

 Dim languageChosen As String = Me.Context.Request.Params("langId")

 ' Code for CultureInfo
 Dim cultureInfo As System.Globalization.CultureInfo
 cultureInfo = New System.Globalization.CultureInfo(languageChosen)

 ' Code for Setting the CurrentCulture
 Thread.CurrentThread.CurrentCulture = cultureInfo
 Thread.CurrentThread.CurrentUICulture = cultureInfo

 Response.Redirect("Default.aspx", True)

Now, on the next requests to server, I check the current culture by getting the value from CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, and this always shows “en”, even if I the user has picked up “el-GR”.

Where might the problem be?

Do I have to save user preferred language in between requests, for example in a session? And then set it to System.Thread.CurrentThread.CurrentCulture at the start of every page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:51:47+00:00Added an answer on May 21, 2026 at 11:51 pm

    I have found the solution to the problem.

    1) I had to save the user preference in Session.
    2) Each time a page is loaded, I now set the Thread.CurrentThread.CurrentCulture after having built the cultureInfo based on the Session saved language preference of the user. The point of code that I do this is in the InitializeCulture override. In other words, my pages override the InitializeCulture as follows:

    Protected Overrides Sub InitializeCulture()
        Dim l_languageChosen As String = Session("language")
    
        ' Code for CultureInfo
        Dim cultureInfo As System.Globalization.CultureInfo
        cultureInfo = New System.Globalization.CultureInfo(l_languageChosen)
    
        ' Code for Setting the CurrentCulture
        Thread.CurrentThread.CurrentCulture = cultureInfo
        Thread.CurrentThread.CurrentUICulture = cultureInfo
    
        MyBase.InitializeCulture()
    
    End Sub
    

    3) In order to avoid having all my pages override this method and avoid repetition of code, I have created a super class “MyWebPage” which does the override (and which inherits from System.Web.UI.Page) and then I made all my pages inherit from MyWebPage.
    4) Of course, the server code that responded to user change language requests changed accordingly to save the language preference in the session, after having set the Thread.CurrentThread.CurrentCulture and CurrentUICulture
    5) I have also set the globalization tag in my web.config as follows:

    <globalization
      uiCulture="auto"
      culture="auto"
      enableClientBasedCulture="true" />
    

    This allowed me to detect the language preference of user set in his/her browser so that I can initially set the preferred language.

    6) In my global.asax I save the language preference detected from browser as follows:

    Session.Add("language", System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName)
    

    Now everything works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the .NET's Uri implementation. It seems that if the
I have a problem that I have not faced before: It seems that the
I have a problem that seems so senseless that I'm sure I'm missing something
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
I have an issue that seems like very flaky behavour, is this a problem
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
This seems like a simple problem: I have a WF4 activity that guides the
I have a strange problem that I can't seem to solve. I've quite a
I have a code problem which stems from the fact that I am using
I have a very simple C# DataTable problem that I cannot seem to wrap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.