或者最好能介绍一下php查域名跟用c#查域名有什么区别?
解决方案 »
- 多线程中使用Invoke出现重复操作怎么解决?
- ActiveX插件自动更新的问题,困扰很久,求助!
- c# 无法使用lostfocus事件
- 生成WORD的问题
- 求救,C#读取Windows性能监控器数据报错
- 出现一个这样的问题?
- 当用backgroundworker操作com的时候遇到的问题
- 请教类的设计
- 在C#中如何用变量名中内容替换变量名的一部分(急)
- 未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。这是什么错误啊
- 我在用.NET自带的测试工具ACT对Web 服务器进行性能测试,查看测试结果的时候,发现提示当前脚本错误,错误类型是对象不支持该属性和方法
- 怎么何并数组呢?
whois.aspsir.com若需要源码,请MSN联系我[email protected]
{
tempserver = result.Substring(pos,result.Length - pos );
tempserver = tempserver.Substring(0,tempserver.IndexOf("\n"));
result = ConnectWhoisServer(tempserver.Trim(),Domain);
}
<1>请求的名称有效并且在数据库中找到,但是它没有相关的正确的数据来被解析。
<2>由于目标机器积极拒绝,无法连接解决方法...?
//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.";
}
}
}
}
用该方法做的域名查询程序已经可以用了!!!
不用任何第三方控件,直接查询whois数据库欢迎指导:
单个whois查询:
http://www.sba.com.cn/advertise/whoisvb.aspx
多个域名查询:
http://www.sba.com.cn/advertise/whoisvb3.aspx