How to get user's culture at run time ?

 Posted by Bharathi Cherukuri on 7/30/2012 | Category: ASP.NET Interview questions | Views: 1387 | Points: 40

Below are the steps to get user's culture at run time.

1. In the first step, you have to get the Request object’s UserLanguages property.
2. Then, you have to use the returned value with the CultureInfo class to create an object representing the user’s current culture.


The following code gets the user’s culture and displays the English name and the abbreviated name of the culture in a label the first time the page is displayed:

private void Page_Load(object sender, System.EventArgs e)
// Run the first time the page is displayed
if (!IsPostBack)
// Get the user's preferred language.
string sLang = Request.UserLanguages[0];
// Create a CultureInfo object from it.
CultureInfo CurrentCulture = new CultureInfo(sLang);
lblCulture.Text = CurrentCulture.EnglishName + ": " +

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response