How to get country, country code and city name by IP address in C#?

Posted on 2009-07-10
Last Modified: 2012-06-27
How to get country, country code and city name by IP address in C#?
Question by:PapaStrumpf
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 53

Accepted Solution

Dhaest earned 500 total points
ID: 24820962
LVL 53

Expert Comment

ID: 24820963
You can get the IP Address by - Request.ServerVariables("REMOTE_ADDR")

You can download the Ip-to-country database from:

and the country information database from:

SourceForge link to the Country Information Database is:

LVL 53

Expert Comment

ID: 24820965
IPAddressExtensions - extending the System.Net.IPAddress class

Information provided
Country name (eg. Australia)
Country ISO 3166 2-Code (eg. AU)
Country ISO 3166 3-Code (eg. AUS)
Registry. (eg. APNIC)
Date the IP Address (range) was added to the data source (if known).


Expert Comment

ID: 24820966

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pressing download button in c# 7 47
Securing WEBAPI on Azure 2 55
Need help with another query 10 54
How to get the range for the percentage from user input. 4 24
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question