Tue Apr 12, 2016 7:22 pm
Using IP2Location;
private void Query(string strIPAddress, string billingCountry)
{
IPResult oIPResult = new IP2Location.IPResult();
try
{
if (strIPAddress != "")
{
IP2Location.Component.IPDatabasePath = "C:\\Program Files\\IP2Location\\Database\\IP-COUNTRY.SAMPLE.BIN";
oIPResult = IP2Location.Component.IPQuery(strIPAddress);
switch(oIPResult.Status.ToString())
{
case "OK":
if (oIPResult.CountryShort == billingCountry) {
// buyer is from the same country by IP address
} else {
// buyer is from the different country by IP address
}
break;
case "EMPTY_IP_ADDRESS":
Response.Write("IP Address cannot be blank.");
break;
case "INVALID_IP_ADDRESS":
Response.Write("Invalid IP Address.");
break;
case "MISSING_FILE":
Response.Write("Invalid Database Path.");
break;
}
}
else
{
Response.Write("IP Address cannot be blank.");
}
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
finally
{
oIPResult = null;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.