Search code examples
c#asp.net-mvccurrentculture

ASP.NET MVC CurrentCulture, from user or server?


Quick question that I couldn't find a clear answer on, if I get the CurrentCulture of a thread in an MVC application, is this the culture based on the user's browser/OS, or the culture that is set on the server?

Thanks


Solution

  • If you enabled enableClientBasedCulture in your Web.Config:

    <system.web>
        <globalization enableClientBasedCulture="true" />
    </system.web>
    

    Then client culture will be used, otherwise it will use the server culture.

    You can also set a fallback culture in case the client didn't send the AcceptLanguage header, by setting the culture and uiCulture properties as well:

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

    See MSDN