I'm using a method to get an IipLocation object from an IP address. This is the code that returns the Location object:
public IIpLocation GetIpLocation(IPAddress ipAddress)
{
ipAddress.CheckNull("ipAddress");
IIpLocation ipLocation = null;
try
{
//Try to look up the location using MaxMind.
Location location = GetMaxMindIpLocation(ipAddress);
//If the postal code is not present, then try to look it up with GeoNames.
if (location != null && (location.PostalCode == null || location.PostalCode.Equals("")))
{
location.PostalCode = GetPostalCodeFromGeoNames(location);
}
if (location != null)
{
ipLocation = new GeoIpLocation(location);
}
}
catch (NullReferenceException)
{
Log.ErrorFormat(Resources.log_maxMindLookupFailed, ipAddress);
}
return ipLocation;
}
The IipLocation object has the following properties: Region
, RegionName
, CountryCode
, City
, Postal Code
, Latitude
, Longitude
. However, I need the State and County. How can I get the state and county from the information that I have?