AJAX查询域名
来源:互联网 发布:2015中国外汇储备数据 编辑:程序博客网 时间:2024/04/28 17:52
[ASPX]
[CS]
演示: http://skyover.dollarscn.com/host.aspx :)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Host.aspx.cs" Inherits="Host" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script>
var div;
function load(){
div = document.getElementById("info");
}
if(window.attachEvent)
window.attachEvent("onload",load);
else
window.addEventListener("load",load,false);
function check(){
div.style.display = "";
div.innerHTML = "正在查询,请稍候";
document.getElementById("Button1").disabled = true;
Host.Check(document.getElementById("Text1").value,new Array(".com",".net",".org"),check_Callback);
}
function check_Callback(res){
if(res.error!=null){
alert(res.error);
}else{
div.innerHTML = "";
for(var i=0;i<res.value.length;i++){
div.innerHTML += (res.value[i].Domain + ":" + (res.value[i].IsRegistered?"已注册":"未注册") + "<br />");
}
}
document.getElementById("Button1").disabled = false;
}
function whois(){
div.style.display = "";
document.getElementById("Button2").disabled = true;
div.innerHTML = "正在查询,请稍候";
Host.Whois(document.getElementById("Text2").value,whois_Callback);
}
function whois_Callback(res){
if(res.error!=null){
alert(res.error);
}else{
div.innerHTML = res.value;
}
document.getElementById("Button2").disabled = false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
查询域名:
<input id="Text1" type="text" onkeyup="document.getElementById('Button1').disabled=(value.length==0);if(event.keyCode==13 && value.length>0)check();" />
<input id="Button1" disabled="true" type="button" value="查询域名" onclick="check()"; /><br />
Whois:
<input id="Text2" type="text" onkeyup="document.getElementById('Button2').disabled=(value.length==0);if(event.keyCode==13 && value.length>0)whois();" />
<input id="Button2" disabled="true" type="button" value=" Whois " onclick="whois();" /><br />
<div style="margin-top:6px;padding:6px;border:solid 1px skyblue;background-color:#def;display:none;width:600px;word-break:break-all;font-family:Tahoma;font-size:14px;" id="info">
</div>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script>
var div;
function load(){
div = document.getElementById("info");
}
if(window.attachEvent)
window.attachEvent("onload",load);
else
window.addEventListener("load",load,false);
function check(){
div.style.display = "";
div.innerHTML = "正在查询,请稍候";
document.getElementById("Button1").disabled = true;
Host.Check(document.getElementById("Text1").value,new Array(".com",".net",".org"),check_Callback);
}
function check_Callback(res){
if(res.error!=null){
alert(res.error);
}else{
div.innerHTML = "";
for(var i=0;i<res.value.length;i++){
div.innerHTML += (res.value[i].Domain + ":" + (res.value[i].IsRegistered?"已注册":"未注册") + "<br />");
}
}
document.getElementById("Button1").disabled = false;
}
function whois(){
div.style.display = "";
document.getElementById("Button2").disabled = true;
div.innerHTML = "正在查询,请稍候";
Host.Whois(document.getElementById("Text2").value,whois_Callback);
}
function whois_Callback(res){
if(res.error!=null){
alert(res.error);
}else{
div.innerHTML = res.value;
}
document.getElementById("Button2").disabled = false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
查询域名:
<input id="Text1" type="text" onkeyup="document.getElementById('Button1').disabled=(value.length==0);if(event.keyCode==13 && value.length>0)check();" />
<input id="Button1" disabled="true" type="button" value="查询域名" onclick="check()"; /><br />
Whois:
<input id="Text2" type="text" onkeyup="document.getElementById('Button2').disabled=(value.length==0);if(event.keyCode==13 && value.length>0)whois();" />
<input id="Button2" disabled="true" type="button" value=" Whois " onclick="whois();" /><br />
<div style="margin-top:6px;padding:6px;border:solid 1px skyblue;background-color:#def;display:none;width:600px;word-break:break-all;font-family:Tahoma;font-size:14px;" id="info">
</div>
</div>
</form>
</body>
</html>
[CS]
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AjaxPro;
using System.Drawing;
using System.Net;
using System.IO;
using System.Text;
using System.Collections.Specialized;
public partial class Host : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Utility.RegisterTypeForAjax(typeof(Host));
}
public struct CHECKRESULT {
public string Domain;
public string Type;
public bool IsRegistered;
}
static string Post(string serviceUrl, string content) {
string response;
Encoding encoding = Encoding.GetEncoding("GB2312");
HttpWebRequest wrq = WebRequest.Create(serviceUrl) as HttpWebRequest;
wrq.Method = "POST";
wrq.Accept = "*/*";
wrq.Referer = serviceUrl;
wrq.ContentLength = content.Length;
byte[] bytes = encoding.GetBytes(content);
using (Stream stream = wrq.GetRequestStream()) {
stream.Write(bytes, 0, bytes.Length);
}
HttpWebResponse wrp = wrq.GetResponse() as HttpWebResponse;
using (Stream stream = wrp.GetResponseStream()) {
using (StreamReader sr = new StreamReader(stream,encoding)) {
response = sr.ReadToEnd();
sr.Close();
}
stream.Close();
}
wrp.Close();
return response;
}
[AjaxMethod]
public CHECKRESULT[] Check(string domain, string[] exts) {
string serviceUrl = "http://www.paycenter.com.cn/cgi-bin/Check";
string content = "name=" + domain;
foreach (string ext in exts)
content += "&suffix=" + ext;
content += "&client=agent27625";
NameValueCollection nvc = HttpUtility.ParseQueryString(Post(serviceUrl,content));
CHECKRESULT[] results = new CHECKRESULT[exts.Length];
int index = 0;
foreach (string ext in exts) {
CHECKRESULT rst;
rst.Domain = domain + ext;
rst.Type = nvc["enc"];
rst.IsRegistered = (nvc["chk" + (index+1)] == "0");
results[index] = rst;
index++;
}
return results;
}
[AjaxMethod]
public string Whois(string domain) {
if (domain.ToLower().EndsWith(".cn")) {
string serviceUrl = "http://www.paycenter.com.cn/cgi-bin/NECWhois";
string content = "NECDN=" + domain;
string response = Post(serviceUrl, content);
response = response.Substring(response.IndexOf("<p align=/"center/"> </p>") + 30);
response = response.Replace(response.Substring(response.IndexOf("<table width=/"100%/" border=/"0/" cellspacing=/"0/" cellpadding=/"0/">") + 63), "");
return response;
} else {
string serviceUrl = "http://whois.paycenter.com.cn/cgi-bin/whois";
string content = "CDomain=" + domain;
string response = Post(serviceUrl, content);
response = response.Substring(response.IndexOf("<p align=/"center/"> </p>") + 30);
response = response.Replace(response.Substring(response.IndexOf("<!--WHOISText -->") + 17), "");
return response;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AjaxPro;
using System.Drawing;
using System.Net;
using System.IO;
using System.Text;
using System.Collections.Specialized;
public partial class Host : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Utility.RegisterTypeForAjax(typeof(Host));
}
public struct CHECKRESULT {
public string Domain;
public string Type;
public bool IsRegistered;
}
static string Post(string serviceUrl, string content) {
string response;
Encoding encoding = Encoding.GetEncoding("GB2312");
HttpWebRequest wrq = WebRequest.Create(serviceUrl) as HttpWebRequest;
wrq.Method = "POST";
wrq.Accept = "*/*";
wrq.Referer = serviceUrl;
wrq.ContentLength = content.Length;
byte[] bytes = encoding.GetBytes(content);
using (Stream stream = wrq.GetRequestStream()) {
stream.Write(bytes, 0, bytes.Length);
}
HttpWebResponse wrp = wrq.GetResponse() as HttpWebResponse;
using (Stream stream = wrp.GetResponseStream()) {
using (StreamReader sr = new StreamReader(stream,encoding)) {
response = sr.ReadToEnd();
sr.Close();
}
stream.Close();
}
wrp.Close();
return response;
}
[AjaxMethod]
public CHECKRESULT[] Check(string domain, string[] exts) {
string serviceUrl = "http://www.paycenter.com.cn/cgi-bin/Check";
string content = "name=" + domain;
foreach (string ext in exts)
content += "&suffix=" + ext;
content += "&client=agent27625";
NameValueCollection nvc = HttpUtility.ParseQueryString(Post(serviceUrl,content));
CHECKRESULT[] results = new CHECKRESULT[exts.Length];
int index = 0;
foreach (string ext in exts) {
CHECKRESULT rst;
rst.Domain = domain + ext;
rst.Type = nvc["enc"];
rst.IsRegistered = (nvc["chk" + (index+1)] == "0");
results[index] = rst;
index++;
}
return results;
}
[AjaxMethod]
public string Whois(string domain) {
if (domain.ToLower().EndsWith(".cn")) {
string serviceUrl = "http://www.paycenter.com.cn/cgi-bin/NECWhois";
string content = "NECDN=" + domain;
string response = Post(serviceUrl, content);
response = response.Substring(response.IndexOf("<p align=/"center/"> </p>") + 30);
response = response.Replace(response.Substring(response.IndexOf("<table width=/"100%/" border=/"0/" cellspacing=/"0/" cellpadding=/"0/">") + 63), "");
return response;
} else {
string serviceUrl = "http://whois.paycenter.com.cn/cgi-bin/whois";
string content = "CDomain=" + domain;
string response = Post(serviceUrl, content);
response = response.Substring(response.IndexOf("<p align=/"center/"> </p>") + 30);
response = response.Replace(response.Substring(response.IndexOf("<!--WHOISText -->") + 17), "");
return response;
}
}
}
演示: http://skyover.dollarscn.com/host.aspx :)
http://www.cnblogs.com/skyover/archive/2005/12/03/290047.aspx
- AJAX查询域名
- ajax和jsp组合进行域名查询
- 域名查询
- 域名查询
- 域名查询
- ajax跨域名
- ajax跨域名
- ajax跨域名访问
- ajax跨域名访问
- C#域名whois查询
- WebService实例-域名查询~
- 域名查询类
- C#域名查询
- C#独立域名查询
- C#独立域名查询
- 域名WHOIS查询
- 域名查询代码
- 域名查询配置
- 计算名次排序
- 一个小小的实用控件
- CSS 控件适配器工具包对事件处理的 Bug 以及修正办法
- 為什麼PetShop要分成這麼多的Project?
- 痛并努力着-在asp.net中如何从视频文件中抓取一桢并生成图像文件
- AJAX查询域名
- AJAX实现的购物车,使用Cookie保存。
- viPlugin for eclipse
- 对Web页面元素的绝对唯一引用方法
- CSS 控件适配器的菜单样式解释
- 软件产品界面设计-培训PPT发布
- 是否该学PetShop将Model和BLL分开?
- 您觉得目前网页最小字体应该多大呢?
- DevExpress.NET.v3 for 2003汉化包