用ASP.Net编写的查询域名的程序




  http://aspx1.brinkster.com/feidao/named.aspx
  
  这个主机是国外所以对中文支持不太好(原因我在亲密接触ASP.net中说得很清楚)大家如果看不到中文请用选择IE中"编码"---"简体中文".
  
  下面是源
  
  <% @ Page Language="C#" %>
  <% @ Assembly Name=".Net" %>
  <% @ Import Namespace=".Net.Sockets" %>
  <% @ Import Namespace=".Text" %>
  <% @ Import Namespace=".IO" %>
  <% @ Import Namespace=".Collections" %>
  <script language="C#" runat="server">
  void doQuery(Object sender, EventArgs e)
  {
  String strDo = txtDo.Text;
  char chSplit = {'.'};
   arrDo = strDo.Split(chSplit);
  
   nLength = arrDo[1].Length ;
  Hashtable table = Hashtable;
  table.Add("de", "whois.denic.de");
  table.Add("be", "whois.dns.be");
  table.Add("gov", "whois.nic.gov");
  table.Add("mil", "whois.nic.mil");
  
  String strServer ;     // whois server
  // the doname's end is cn then the server is cnnic ,otherwise is networksolutions
   (arrDo[arrDo.Length - 1] "cn")
  {
  strServer = "159.226.6.139" ;
  }
  
  {
  strServer = "whois.networksolutions.com";
  }
  
   (table.ContainsKey(arrDo[1]))
  {
  strServer = table[arrDo[1]].;
  }
   (nLength 2)
  {
  // 2-letter TLD's always default to RIPE in Europe
  strServer = "whois.ripe.net";
  }
  
  String strResponse;
  bool bSuccess = DoWhoisLookup(strDo, strServer, out strResponse);
   (bSuccess)
  {
  txtResult.Text = strResponse;
  }
  
  {
  txtResult.Text = "Lookup failed";
  }
  }
  
  bool DoWhoisLookup(String strDo, String strServer, out String strResponse)
  {
  strResponse = "none";
  bool bSuccess = false;
  
  TCPClient tcpc = TCPClient;
   (0 tcpc.Connect(strServer, 43))
  {
  strDo "\r\n";
  Byte arrDo = Encoding.ASCII.GetBytes(strDo.ToCharArray);
  try
  {
  String str;
  Stream s = tcpc.GetStream;
  s.Write(arrDo, 0, strDo.Length);
  
  StreamReader sr = StreamReader(tcpc.GetStream, Encoding.Default);
  StringBuilder strBuilder = StringBuilder;
  while (-1 != sr.Peek)
  {
  strBuilder.Append(sr.ReadLine+"
  ");
  
  }
  tcpc.Close;
  
  bSuccess = true;
  strResponse = strBuilder.;
  }
  catch(Exception e)
  {
  strResponse = e.;
  }
  
   bSuccess;
  }
  
  {
  strResponse = "Could not connect to Whois server";
   false;
  }
  
   false;
  }
  </script>
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; char=gb2312">
  <title></title>
  </head>
  <body>
  
  <form runat="server">
  Do name: WWW . <asp:TextBox id="txtDo" value="" runat="server" />
  <asp:Button id="btnQuery" _disibledevent=>
  <BR><HR width="100%"><BR>
  <asp:label id="txtResult" runat="server" />
  </form>
  
  </body>
  </html>
Tags: 

延伸阅读

最新评论

发表评论