Tuesday, January 6, 2009

Using GeoIP's GeoLite to find an IP address City using C# .Net

There’s a terrific open source product offered by MaxMind called GeoLite City that is a binary (or CSV) database for doing IP location lookups.  There are many flavors of the GeoIP API that provide optimized access to the .DAT file, including C# and VB.Net (Country only).  The C# version is a collection of 5 classes and is very easy to use:

Dim ls As New LookupService("C:\GeoIP\GeoLiteCity.dat")
Dim IPLoc As Location = ls.getLocation(IPString)