CurrentCulture incorrectly defaulting to en-US in ASP.net

These are alternative places where you could search:

I can’t find anywhere that’s settings the culture to ‘en-US’… but something is.

Thread.CurrentThread.CurrentCulture.Name is outputting ‘en-US’
Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol is outputting ‘$’

Try looking for the InitializeCulture method, this method is overridden in ASP.Net pages to set the Culture like:

protected override void InitializeCulture()
{
    var hidden = this.Request.Form["hidden"];
    var culture = this.Request.Form[hidden];
    if (!string.IsNullOrWhiteSpace(culture))
    {
        this.Culture = culture;
        this.UICulture = culture;
    }

    base.InitializeCulture();
}

Try to look for the following assembly attributes:

    [assembly: AssemblyCulture("en-US")]
    [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]

Try to look for the following page directive attributes:

    <%@ Page Culture="en-US" UICulture="en-US" Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

Try to look in web.configs:

<globalization uiCulture="en-US" culture="en-US" enableClientBasedCulture="false" />

Edit 1

Try to look for HttpHandlers or HttpModules trying to set the language

Try to look in the web.config hierarchy (at the server, <wwwroot> means the root folder of your IIS Web Site)

  1. Global machine. <windir>\Microsoft.NET\Framework\<ver>\Config\Machine.config
  2. Root Web config. <windir>\Microsoft.NET\Framework\<ver>\Config\Web.config
  3. Website. <wwwroot>\Web.config
  4. Web application. <wwwroot>\<webapp>\Web.config
  5. Folder. <wwwroot>\<webapp>\<dir>\Web.config

If you have multiple servers (web farm), check you are being redirected to the correct server (the one you are checking the configuration), in order to do it you can use the ip of the desired server or configure your host files in your client computer

Leave a Comment

tech