There are situations where we have to track visitors. The tracking might include the country from the visitor has browsed the website. These statistics are often important.
This project provides a library to resolve the country name given an IP. The project uses the Codeplex IPExtensions projects. This project has embedded information of the various ip address ranges assigned to different countries.
The major advantage of this method is a single DLL. It does not require any database setup etc. You just need to add reference to the IpToCountryLib DLL provided in the solution.
To resolve the country name, the library API to be used is "GetCountry". GetCountry takes in a string parameter which is the IP Address and returns the country name as the out parameter.
This is the code of the function,
public bool GetCountry(string userHostIpAddress, out string countryName)
bool result = false;
countryName = string.Empty;
if (IPAddress.TryParse(userHostIpAddress, out ipAddress))
countryName = ipAddress.Country();
result = true;
Public Function GetCounTry(ByVal userHostIpAddress As String, ByRef counTryName As String) As Boolean
Dim result As Boolean = False
counTryName = String.Empty
If String.IsNullOrEmpty(userHostIpAddress) Then
Dim ipAddress As IPAddress
If IPAddress.TryParse(userHostIpAddress,out ipAddress) Then
counTryName = ipAddress.CounTry()
result = True
To use the function you will do a call like this,
IPToCountry _lib = new IPToCountry();
Dim _lib As IPToCounTry = New IPToCounTry()
Dim counTry As String
I have attached the source code and also an exe for the application. The application attached contains a WPF application using the library and demonstrating the feature.
AttachmentsSource Code (663-262226-IPToCountry.rar)Exe (663-262226-EXE.rar)
|Author: Ashish Gupta||Member Level: Bronze||Revenue Score: |
|Hello, I want to learn about dot net please send me some code, how we can use sesion, security, I do not know how we can apply all this and if possible please send me a project that will clear my all basic as well|
|Author: Anil||Member Level: Bronze||Revenue Score: |
nice project i need the dll sourse code
|Author: divya||Member Level: Bronze||Revenue Score: |
|really good work especially for security reasons. But can u provide me with the source code and the details about executing the project? Iam doing my final year engg .so pls help me|
|Author: Manish||Member Level: Bronze||Revenue Score: |
|really good work especially for security reasons. But can u provide me with the source code and the details about executing the project? Iam doing my final year MCA .so pls help me|
|Author: sangee||Member Level: Bronze||Revenue Score: |
|nice project thank u...|
|Author: Rahul||Member Level: Bronze||Revenue Score: |
|i am pursuing my third engineering i am interested in networking & i have to submit a mini project this year so please suggest me the right ans. i would like to do project in networking using vb.net|
|Author: vinaysrivastava||Member Level: Bronze||Revenue Score: |
|nice project for security.but i want to know more detail of the program.i am final year mca student|
|Author: Kritika Yadav||Member Level: Gold||Revenue Score: |
|hey really nice code. do you have any code to get domain from where we reached the current page.|
|Author: premkumar||Member Level: Silver||Revenue Score: |
|how can i implement this in my application...i tried am not getting anything.|
|Author: Pritom Nandy||Member Level: Gold||Revenue Score: |
|Indeed a very good article and effective as I needed it on my project.|
|Author: Johney Joseph||Member Level: Bronze||Revenue Score: |
very nice to post such a project. this's a most wanted snippet needed by many serious developers.
|Author: Neeraj Kumar SIngh||Member Level: Silver||Revenue Score: |
how we run this project?
how we use it in our application?
|Author: siva||Member Level: Gold||Revenue Score: |
Its really nice. I would like learn such type of things.
It will be greatful for me to send the files.