Disabling ASP.NET 2.0 browser culture detection RRS feed

  • Question

  • User-1460930657 posted
    okay the problem is , ASP.NET 2.0 by default detects the culture of the browser request and use local resources for this culture if found .. now in my scenario .. i want to make the site use enlgish culture as a defualt and then the use can change the languge explicitly from a combo box in the master page [ the last part is working :) ... the issue is in the first web-site request that detects the browswe ]

    here is my implementation
       <globalization  enableClientBasedCulture="false" culture="en-US" uiCulture="en-US"  requestEncoding="utf-8" responseEncoding="utf-8"  />

    this is baseClass that all web-pages inherit from:
    protected override void InitializeCulture()
            string lang = string.Empty;//default to the invariant culture
            HttpCookie cookie = Request.Cookies["SelLang"];

            if (cookie != null && cookie.Value != null)
                lang = cookie.Value;
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang);


    thanx in advance

    Sunday, July 16, 2006 6:52 AM


  • User83354550 posted


    By simply setting your culture/UICulture to "auto" and then setting up a default resource file which does not explicitly state a culture setting in its filename, you are ensuring this is loaded as default at runtime.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 14, 2007 10:41 AM