获得客户IP地址和和所在区域物理地址

1 添加IPLocation.dll到bin 添加引用

2 添加ip数据库文件 QQWry.Dat 到项目

3 调用方法
       

代码分享string conn, ipstr, addstr="";
        conn = Server.MapPath("inc/QQWry.Dat");
        ipstr = TextBox1.Text.Trim();
        try
        {
            addstr = IPLocation.IPLocation.IPLocate(conn, ipstr);
        }
        catch(Exception)
        {
            Label1.Text = "IP地址错误!";
        }
        Label1.Text = "IP:" + ipstr + "   地址:" + addstr;

posted @ 2009-07-17 16:47  M.JQ  阅读(401)  评论(1)    收藏  举报