或者最好能介绍一下php查域名跟用c#查域名有什么区别?

解决方案 »

  1.   

    用DNS类,解析不到的域名就可以认为它不存在。(但是不绝对)
      

  2.   

    我做的一个域名查询的WEB SERVICE
    whois.aspsir.com若需要源码,请MSN联系我[email protected]
      

  3.   

    if (pos != -1) 
    {
    tempserver = result.Substring(pos,result.Length - pos );
    tempserver = tempserver.Substring(0,tempserver.IndexOf("\n"));
                
     
    result = ConnectWhoisServer(tempserver.Trim(),Domain);
    }
      

  4.   

    C#查询信息时经常会出现的异常信息:
    <1>请求的名称有效并且在数据库中找到,但是它没有相关的正确的数据来被解析。
    <2>由于目标机器积极拒绝,无法连接解决方法...?
      

  5.   

    //我把WHOIS.ASPSIR.COM的源代码贴上,希望你对你有帮助
    //whois.asmx.cs
    //url whois.aspsir.comusing System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Web;
    using System.Web.Services;
    using System.Net;
    using System.Net.Sockets;
    using System.Text;
    using System.Collections.Specialized;namespace WhoisService
    {
    /// <summary>
    /// Summary description for whoisService.
    /// </summary>
    /// 
    [WebService(Namespace="http://whois.aspsir.com/",Description="<b>A web service which performs Whois Lookups. <br><br>Whois for</b><br>.com, .net, .org, .edu, .biz, .info,.mil,<br> .com.cn, .net.cn, .org.cn, <br>.bj.cn, .sh.cn,.tj.cn, .cq.cn, .he.cn, .nm.cn,.ln.cn,.jl.cn,.hl.cn,.js.cn,.zj.cn,.ah.cn,.hb.cn,<br>.hn.cn,.gd.cn,.gx.cn,.hi.cn,.sc.cn,.gz.cn,.yn.cn,.xz.cn,.sn.cn,.gs.cn,.qh.cn,.nx.cn,.xj.cn,<br>.tw.cn,.hk.cn,and .mo.cn..<br><b>The more infomation is available at: http://www.aspsir.com and http://www.ycweb.net.</b>")]
    public class Whois : System.Web.Services.WebService
    {
    public Whois()
    {
    //CODEGEN: This call is required by the ASP.NET Web Services Designer
    InitializeComponent();
    } #region Component Designer generated code

    //Required by the Web Services Designer 
    private IContainer components = null;

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if(disposing && components != null)
    {
    components.Dispose();
    }
    base.Dispose(disposing);
    }

    #endregion // WEB SERVICE EXAMPLE
    // The HelloWorld() example service returns the string Hello World
    // To build, uncomment the following lines then save and build the project
    // To test this web service, press F5 [WebMethod]
    public string Lookup(string strDomain)
    {
    try
    {
    string result="";
    string server="whois.internic.net";
    string ext=".com";
    int port=43;
    int address=-1;
    string domain=strDomain.Trim().ToLower();

    if(domain.StartsWith("www."))
    {
    domain=domain.Substring(4,domain.Length-4);
    }

    if(domain=="" || domain.IndexOf(",")!=-1|| domain.IndexOf(";")!=-1|| domain.IndexOf("_")!=-1|| domain.IndexOf(".")==-1)
    {
    result="Please enter a valid domain name.";
    }
    else
    {
    address=domain.IndexOf(".");
    ext=domain.Substring(address);

    switch (ext)
    {
    case ".com":
    case ".net":
    case ".org":
    default:
    server="whois.crsnic.net";
    //server="whois.internic.net";
    break;
    case ".biz":
    case ".info":
    case ".mil":
    server="whois.networksolutions.com";
    break;
    case ".edu":
    server="whois.educause.net";
    break;
    case ".cn":
    case ".com.cn":
    case ".net.cn":
    case ".org.cn":
    //case ".gov.cn": case ".bj.cn":
    case ".sh.cn":
    case ".tj.cn":
    case ".cq.cn":
    case ".he.cn":
    case ".nm.cn":
    case ".ln.cn":
    case ".jl.cn":
    case ".hl.cn":
    case ".js.cn":
    case ".zj.cn":
    case ".ah.cn":
    case ".hb.cn":
    case ".hn.cn":
    case ".gd.cn":
    case ".gx.cn":
    case ".hi.cn":
    case ".sc.cn":
    case ".gz.cn":
    case ".yn.cn":
    case ".xz.cn":
    case ".sn.cn":
    case ".gs.cn":
    case ".qh.cn":
    case ".nx.cn":
    case ".xj.cn":
    case ".tw.cn":
    case ".hk.cn":
    case ".mo.cn":
    server="whois.cnnic.net.cn";
    break;
    } //starting lookup
    UTF8Encoding utf8 = new UTF8Encoding();
    // Connect to the whois server
    TcpClient tcpClient = new TcpClient();
    tcpClient.Connect(server,port);
    NetworkStream networkStream  = tcpClient.GetStream();
    // Send the domain name to the whois server

    domain=domain.Replace("0x00","");
    byte[] buffer=Encoding.GetEncoding("GB2312").GetBytes(domain + "\r\n");
    //byte[] buffer = utf8.GetBytes(domain + "\r\n");
    networkStream.Write(buffer,0,buffer.Length);
    // Read back the results
    buffer = new byte[10240]; int i = networkStream.Read(buffer,0,buffer.Length);
    while ( i > 0)
    {
    i = networkStream.Read(buffer,0,buffer.Length);
    result += utf8.GetString(buffer);
    //result +=Encoding.GetEncoding("GB2312").GetString(buffer);
    }
    networkStream.Close();
    tcpClient.Close();
    }
    //return the lookup resutlt
    result=result.Replace("\u0000","");
    return result;   
    }

    catch(Exception e)
    {
    return e.Message;
    //return "Sorry.Lookup is false.Please check the format of domain or internet connection.";
    }
    }

    }
    }
      

  6.   

    直接查询whois数据库谢谢各位的帮助,问题已经解决。
    用该方法做的域名查询程序已经可以用了!!!
    不用任何第三方控件,直接查询whois数据库欢迎指导:
    单个whois查询:
    http://www.sba.com.cn/advertise/whoisvb.aspx
    多个域名查询:
    http://www.sba.com.cn/advertise/whoisvb3.aspx