黑客风云——风云网络
设为首页 加入收藏 我要投稿 网站地图
您现在的位置: 黑客风云 >> 黑客文章 >> 网管频道 >> 网站建设 >> 文章正文
[推荐]用VB.net和ASP.net实现Whois.aspx查询系统
      ★★★★
用VB.net和ASP.net实现Whois.aspx查询系统
文章整理发布:黑客风云 文章来源:www.05112.com 更新时间:2006-4-4

总结:

建立一个whois查询需要以下几步:
1) 用 Imports 语句导入 System,,System.Net,System.IO 和System.Net.Sockets名字空间
2) 用TcpClient 类连接whois远程服务器
送出我们的域名查询
3) 得到WHOIS服务器反应的信息
4) 显示数据
5) 另外,用try catch对 SocketException 类的异常事件进行处理。

注意:在我提供的下拉表中提供了四个常用的whois服务器
whois.cnnic.net.cn (.cn) 查询cn域名
whois.networksolutions.com (.COM, .NET, .EDU)
whois.ripe.net(欧洲)
whois.arin.net(美洲)
互联网日新月异,变化太快,这里是一份whois服务器列表http://wmjie.51.net/swords/blog/index.php?action=show&id=104
已经包含了100多个whois服务器查询网址,你可自行进行添加到DropDownList列表中。

代码清单:

<%@ Page Language="VB" Debug="true" %>
<% @Import Namespace=System %>
<% @Import Namespace=System.Net %>
<% @Import Namespace=System.IO %>
<% @Import Namespace=System.Net.Sockets %>

<script runat="server">
sub querywhois(obj as object, e as EventArgs)
Dim WhoIsClient As New TcpClient()
Dim WhoIsStream As NetworkStream
Dim WhoIsWriter As StreamWriter
Dim WhoIsReader As StreamReader
Dim Hostname as string
try
Hostname=request.form("domainname") & vbcrlf

WhoIsClient.Connect(request.form("WhoisServer"), 43)
WhoIsStream = WhoIsClient.GetStream()

WhoIsWriter = New StreamWriter(WhoIsStream)
WhoIsWriter.Write(Hostname)
WhoIsWriter.Flush()

WhoIsReader = New StreamReader(WhoIsStream)
lblResponse.Text = "<pre>"
lblResponse.text+="<br><br>Whois.Aspx 查询系统 by swords[E.S.T]<br>" & _
"welcome to my studio:<a href=http://wmjie.51.net/swords target=new>Savor.swords studio</a><br><br>"
while whoisreader.peek() > -1
lblResponse.text+=server.HTMLEncode(WhoIsReader.ReadLine) & "<br>"
end while
lblResponse.text+="</pre>"

WhoIsStream.Close()
WhoIsClient.Close()
catch ex as Exception
lblResponse.Text = ex.message
end try
end sub
</script>

<html>
<head>
<style>
.main {font-family:Verdana; font-size:15px;}
.title {font-family:Verdana; font-size:18px; font-weight:bold;}
</style>
</head>
<body>
<div class="title" align="center">Whois.Aspx 查询系统 by swords[E.S.T]</div>

<form method="POST" name="MainForm" runat="server">
<table>
<tr>
<td class="main" align="right">请选择查询Whois所用的服务器</td>
<td class="main">
<asp:DropDownList class="main" id="WhoisServer" runat="server">
<asp:ListItem value="whois.cnnic.net.cn">whois.cnnic.net.cn (.cn)</asp:ListItem>
<asp:ListItem value="whois.networksolutions.com">whois.networksolutions.com (.COM, .NET, .EDU)</asp:ListItem>
<asp:ListItem value="whois.ripe.net">whois.ripe.net(欧洲)</asp:ListItem>
<asp:ListItem value="whois.arin.net">whois.arin.net(美洲)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="main" align="right">查询的域名或IP地址:</td>
<td class="main"><input type="text" class="main" name="DomainName" value="swords.cn"></td>
</tr>
<tr>
<td class="main"> </td>
<td class="main"><input type="Submit" id="btnSubmit" OnServerClick="querywhois" value="开始查询" runat="server" /></td>
</tr>
</table>
<br><br>
<asp:Label class="main" id="lblResponse" runat="server"/>
</form>
</body>
</html>
测试:

看到了吗?查询后的结果显示了详细的信息,Success! Cheers!

上一页  [1] [2] 

文章录入:cainiaowang    责任编辑:cainiaowang 
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
VIP 专 区
Copyright @2006 黑客风云 ●业务联系:QQ 联系怪人 联系奇人 Email:给怪人发邮件 给奇人发邮件
ICP备案:冀06009886