IPQuery 库使用说明

因之前的文章《IP地址库解析》上传文件错误,导致许多网友运行时出现错误,在此向各位道歉了。

在此奉上使用说明:

============================================
使用说明
============================================
1、下载 qqwry.dat 
http://www.onlinedown.net/soft/19051.htm

2、解压文件,放到网站的bin目录下。
形成如下结构:



3、浏览首页: Default.aspx 即可

============================================
IPQUERY.DLL 使用说明
============================================
1、在网站根目录下初始化IP数据库文件

protected void Application_Start(object sender, EventArgs e)
{
    // 这里初始化查询引擎,设置 qqwry.dat 的网站根目录
    string ipData = Server.MapPath(@"~\bin\qqwry.dat");
    IPQuery.Facade.SingleQuery.Instance.SetDataFilePath(ipData);
}

2、查询ip地址

/// <summary>
/// 点击查询按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnQuery_Click(object sender, EventArgs e)
{
    string ip = this.TextBox1.Text;
    if (string.IsNullOrEmpty(ip))
    {
        this.Page.Response.Write("大哥,好歹也给个地址啊!");
        return;
    }
    this.Page.Response.Write(this.Output(SingleQuery.Instance.Find(ip)));
}
     
/// <summary>
/// 输出IP地址记录
/// </summary>
/// <param name="ipRecord"></param>
/// <returns></returns>
private string Output(IPAddressRecord ipRecord)
{
    if (null != ipRecord)
    {
        return string.Format("{0} - {1} {2} {3}", AddressConvert.UInt32ToIpV4String(ipRecord.IPStart), AddressConvert.UInt32ToIpV4String(ipRecord.IPEnd), ipRecord.Country, ipRecord.Area);
    }
    return string.Empty;
}

============================================
××××××××××××××××××××××××××××××××××××××××××××
作者:孤剑
http://www.cnblogs.com/alonesword/

http://blog.youkuaiyun.com/alonesword/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值