Library tutorials & articles
Extracting the Country from the IP Address:- How To?
By Amit Gupta, published on 13 Mar 2004
Introduction
Internet is vast & is spread across many countries & continents. Knowing the country of a visitor to your website can be a tedious task, if you don't know how to proceed.
The Need??
But firstly, the question that arises is why would you be interested in knowing the country of visitors to your website. The reasons can be many. Some of them are:
How??
Ok, you have the reason to know the country of your visitor, now the question is, how to proceed? How can you know the Country of your Visitor?
IP & the Country??
Every internet user has a unique IP address, or in other words, every computer connected to internet, has a unique IP address. IP address is a numerical address to refer to a computer. The example of an IP address is
120.36.162.75
Every ISP(Internet Service Provider) has been allocated a range of IP address which it can provide to its users. So, through an IP address, we can find out the country of the visitor.
The Need??
But firstly, the question that arises is why would you be interested in knowing the country of visitors to your website. The reasons can be many. Some of them are:
- Displaying Geo-Specific Ads
- Targetting Geo-Specific Visitors
- Maintaining a Log of Visitors to the website
- Displaying the website in local language
- Re-directing the visitor to local website
- Displaying Product Prices in Local Currencies
How??
Ok, you have the reason to know the country of your visitor, now the question is, how to proceed? How can you know the Country of your Visitor?
IP & the Country??
Every internet user has a unique IP address, or in other words, every computer connected to internet, has a unique IP address. IP address is a numerical address to refer to a computer. The example of an IP address is
120.36.162.75
Every ISP(Internet Service Provider) has been allocated a range of IP address which it can provide to its users. So, through an IP address, we can find out the country of the visitor.
Related articles
Related discussion
-
Header and Footer in Web page print
by fhajaj (4 replies)
-
help me to get simple requirement
by Slicksim (1 replies)
-
Gridview -> Template Field -> Button
by antti.simonen (1 replies)
-
Classic ASP : Page expires
by chezhian_in05 (0 replies)
-
ASP VS PHP
by paulfp (9 replies)
Related podcasts
-
ASP.NET Caching and Performance
Steve Smith, owner of ASP Alliance and Lake Quincy Media joins us today to teach us about some hidden gems in ASP.NET caching and performance. Steve’s expertise in this area comes from first-hand experience as Lake Quincy’s ad system serves over 60 requests per second and handles over 150 million...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Microsoft Dynamics CRM Technical Consultant
in Netherlands (€50K-€90K per annum) -
Technical Support Engineer EMEA
in Reading (£50K-£50K per annum) -
Solutions Engineer
in Reading (£50K-£60K per annum)
I just wrote a lasted sample which describes how to get countries and city from IP address and the sample contains a IP database.If you want to get the sample code,Please visite http://www.treaple.com/bbs/index.php or http://www.treaple.com/bbs/thread-17-1-1.html
First of all,you should get a database which includes all countries IP details.
and then convert IP address to decimal to find the exact country name by the decimal .
I hope that this article can be used for you
http://www.treaple.com/ArticlesDetails.aspx?id=55
cheer.
Though this is a brilliant piece of code, can u guys please explain that what are the datatypes used in the function ipAd2ipNum and also it gives me an error if i use the datatypes like integer, int32, int64...Please reply asap Rohit![Smiley Face [:)]](/emoticons/emotion-1a.gif)
Thanks a lot.![Smiley Face [:)]](/emoticons/emotion-1a.gif)
![Crying [:'(]](/emoticons/emotion-9.gif)
Hi,
First i woud like to thank you fom the bottom of my heart, on this wounderful, well orginized article, it really helped me a lot, i have been looking for a one like this for a long time
THANX A LOT
btw, i guese you have forgotten about the database anyway,
i'll do u simple favor for you and others as little return for this article
the link for the latest CSV Values
http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip
Once again, Thanx a lot
Best Regards
How to download the MS Access database?
If your wondering why "strIP = Request.ServerVariables("HTTPREMOTEADDR")" returns no IP address change it too "strIP = request.servervariables("REMOTE_ADDR")" and this will now work !
This thread is for discussions of Extracting the Country from the IP Address:- How To?.