0
我想获取我的网站访问者的地理位置,并将其存储在我的数据库中,并已获取IP地址。我有我的网站访问者的IP地址,我怎么能得到他们的地理位置吗?
我使用asp.net 3.0
protected void Page_Load(object sender, EventArgs e)
{
// Track Visitors
string ipAddress = IpAddress();
string hostName = Dns .GetHostByAddres(ipAddress).HostName;
StreamWriter wrtr = new StreamWriter (Server.MapPath("visitors.log"), true);
wrtr.WriteLine(DateTime .Now.ToString() + " | " + ipAddress + " | " + hostName + " | " + Request.Url.ToString());
wrtr.Close();
}
private string IpAddress()
{
string strIpAddress;
strIpAddress = Request.ServerVariables[ "HTTP_X_FORWARDED_FOR" ];
if (strIpAddress == null)
strIpAddress = Request.ServerVariables[ "REMOTE_ADDR" ];
return strIpAddress;
}
这只是给我的IP地址ñ主机名,我想知道城市和国家太,,,, – Zoya