CultureInfo.CurrentCulture is giving me the wrong culture

thchaver picture thchaver · Jun 28, 2010 · Viewed 10.9k times · Source

I'm trying to get my clients' country, so I use CultureInfo.CurrentCulture. Problem is that when my Canadian customers use my website, they're showing up as American.

It looks like CultureInfo.CurrentCulture is returning my server's country instead of their country. So how do I get my clients' country?

Answer

Thomas Levesque picture Thomas Levesque · Sep 25, 2010

You just need to set the culture attribute to auto in your web.config file:

<system.web>
    <globalization culture="auto" />
<system.web>

This will automatically set the CurrentCulture to the client's culture.

You can also set uiCulture to auto if you're using localized resources.