Jame
Jame

Reputation: 22180

How web page automatically identify country?

I am working in ASP.net and C# . Currently i am designing a signup page for my web application. On that page there is a field "Country", user can specify his country using drop-down list. Now i want to automatically detect user's country and then pre select that country in drop-down list. How do i identify user country.

Upvotes: 1

Views: 1498

Answers (2)

marc.d
marc.d

Reputation: 3844

the users browser already sends you his prevered language and localization with the HTTP-Header

Accept-Language: en-US,en;q=0.8

if you want to change the CurrentCulture based on this information you can add the following to your web.config

<system.web>    
    <globalization culture="auto" uiCulture="auto" enableClientBasedCulture="true" />
    ...snip...

Upvotes: 3

Coding Flow
Coding Flow

Reputation: 21881

You need some kind of IP geolocation database to map the users IP address to a country. There are plenty of services and data files online, just google for geo IP lookup.

EDIT just did a quick google for you this should give you the data you need.

Upvotes: 4

Related Questions