域名Whois信息查询(ASP.NET+C#)

时间:2010-02-24 15:01:40  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:m.Net.Sockets" %>   <% @Import Namespace="System.Text" %>   <% @Import Namespace="System.IO" %>   <html>   <head>   <title>.Com/.Net/.Org/.Cn 域名Whois信息查询</title>   <meta name="keywords&q...
  正文:去年写的了,是从点缀的博客学来的
  看演示请点这里:http://www.ASP/ target=_blank class=infotextkey>aspxboy.com/whois.aspx
  代码如下:
  <% @Page Language="C#" %>
  <% @Import Namespace="System.Net.Sockets" %>
  <% @Import Namespace="System.Text" %>
  <% @Import Namespace="System.IO" %>
  <html>
  <head>
  <title>.Com/.Net/.Org/.Cn 域名Whois信息查询</title>
  <meta name="keywords" content=".Com,.Net,.Org,.Cn 域名Whois信息查询">
  <meta name="generator" content=".Com/.Net/.Org,.Cn 域名Whois信息查询">
  <meta name="description" content=".Com/.Net/.Org,.Cn 域名Whois信息查询">
  <style>
  <!--
  body,input{
   font-family: Tahoma, Verdana; color: #004080; font-size: 12px
   }
  a:link,a:visited{
   text-decoration: none; color: #004080
   }
  -->
  </style>
  </head>
  <body>
  <form id="fmQuery" runat="server">
   要查询的域名域名:
  www.<asp:TextBox id="txtDomain" width="100" value="ASPXBOY.COM" runat="server" />
    <asp:Button id="btnQuery" OnClick="btn_click"
  text="查询!" runat="server" />(只能查询.Com/.Net/.Org/.Cn 域名Whois的信息)      <a href ="WhoisCode.htm" title="View the source code here!">源代码在这里</a>
  <BR><HR width="550" height="1" align="left"><BR>
  <asp:label id="lblResult" runat="server" />
  </form>
  </body>
  </html>
  <script language="C#" runat="server">
  void btn_click(Object sender, EventArgs e)
  {
  String strServer;
  String strDomain = txtDomain.Text;
  String strServerCom = "whois.networksolutions.com";
  String strServerCN = "whois.cnnic.net.cn";
  String strResponse;
  string[] arrDomain = strDomain.Split('.');
  if (arrDomain[1].ToUpper()=="CN")
  {
  
   strServer=strServerCN;
  }
  else
  {
   strServer=strServerCom;
  }
  
  bool blSuccess = IsWhosisSuccess(strDomain, strServer, out strResponse);
  if (blSuccess)
  {
  lblResult.Text = strResponse;
  }
  else
  {
  lblResult.Text = "查找失败....";
  }
  }
  bool IsWhosisSuccess(String strDomain, String strServer,
   out String strResponse)
  {
   strResponse = "none";
   bool blSuccess = false;
   TcpClient tcpc = new TcpClient();
   try
   {
   tcpc.Connect(strServer, 43);
   }
   catch(SocketException ex)
   {
   strResponse = "连接不到该 Whois server,请稍后再试。";
   return false;
   }
  

"域名Whois信息查询(ASP.NET+C#)"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/aspnet/12890.html


关键字:

关于《域名Whois信息查询(ASP.NET+C#)》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td