Using XML HTTP to add a domain name query function to a Web site

Source: Internet
Author: User
Tags chr comments html form html page trim domain client domain name registration
XML when we are ready to build a Web site, we must apply to the domain name registration authority for an Internet domain name, therefore, we usually want to know whether the domain name we are ready to use has been registered, at this time, you can access the NIC site http://www.nic.net, click " Whois link to enter the domain name you want to query, you can get the results we need.

Whois for. Queries for the international top-level domain names of COM,. NET and. org return all WHOIS data, including domain name registrars, management contracts, contact details (phone, e-mail, address), billing contact, technical support, and domain name information, which is helpful for users to understand a basic situation. In many domain name registrars, there is usually a senior service of whois (domain name query), but the individual cannot provide WHOIS service under general conditions because it does not have the qualification and data of the domain name registrar.

In fact, using the XMLHTTP protocol, each of us can provide domain name details query (WHOIS) service in our own individual, this article describes how to use ASP combined with XMLHTTP programming to achieve this function.

first, the principle

The principle is very simple, domain name query is mainly based on the WHOIS protocol provided by RFC954. In the implementation process, we have our Web access to the NIC site whois, from whois query what we need, and then through the ASP Group Composite Web page back to the client.

At the same time, we use XMLHTTP protocol to achieve the client page without refreshing effect and to the server to retrieve WHOIS data requirements.

The specific process is: the client through XMLHTTP proposed domain name Query request-->web in the ASP listening page to accept the request, use XMLHTTP to send the retrieval command to WHOIS-->whois perform query operations, Return results to our own web (HTML form)-->web after receiving the content, the result is immediately routed to the client-> the client browser uses VBScript to filter out the extra portions of the HTML, picking out the WHOIS data to display.

second, aspxmlhttp programming brief

1. Client HTML page:



<scriptlanguage= "VBScript" >

Subsubmit1_onmouseup ' When the "Query" button is clicked to trigger;

Dimobjxml,objxsl,objfso,strfile,strfilename,strxsl,strurl,theform

Settheform=document.wordfind

window.status= "Retrieving Data ..."

Strurl= "Dns.asp"

Setobjxml=createobject ("Microsoft.XMLHTTP") ' creates Ms's XMLHTTP component;

Stra= "submit=submit&fqdn=" &theform.words.value

Objxml.open "POST", Strurl,false ' using post submission method;

Objxml.setrequestheader "Content-length", Len (stra)

Objxml.setrequestheader "Content-type", "application/x-www-form-urlencoded"

Objxml.sendstra ' Send a message

Xmlget=objxml.responsetext ' Wait for a moment, get the result of the end pass back;

Ifinstr (1,xmlget, "Thisisnotavalid.com.net.org.infoor.bizdomain name", 1) <1andlen (Trim (xmlget)) >100then

Ifinstr (1,xmlget, "thisdomainisavailable", 1) <1then

Ifinstr (1,xmlget, "Registrant:", 1) Then

Strfind1=instr (1,xmlget, "Registrant:", 1)

Else

Strfind1=instr (1,xmlget, "<pre> <fontface=" "Verdana,arial", 1) +65

Strfind2=instr (1,xmlget, "</FONT> </pre>", 1)

Strfind4=strfind2-strfind1

Shtml=mid (XMLGET,STRFIND1,STRFIND4)

theform.comments.value= "Query results:" +CHR (+CHR) +shtml

window.status= "Query result: This domain name is already occupied"

Else

Theform.comments.value= "Congratulations, this domain is available!" "

window.status= Query Result: The domain name is still available! "

endif

Else

Theform.comments.value= "Invalid international top-level domain!" Please enter an international domain name ending with (. com.net.org.infoor.biz), such as sun.com "

window.status= "Invalid international top-level domain!" Please enter an international domain name ending with (. com.net.org.infoor.biz), such as cctv.com "

endif

Setobjxml=nothing

Endsub

</script>


<bodybgcolor= #cccca3 > >

<formmethod= "POST" name=wordfindonsubmit= "Javascript:returnfalse"

Please enter the domain name: <inputtype= "text" value= "cctv.com" name= "words" size= "69"

<inputtype= "Submit" value= "Query" id=submit1name=submit1>

<TEXTAREAname=commentsreadonlyrows=10cols=76> </TEXTAREA>

</form> </body>

2, the end of ASP program:



<%dimxmlGet,objXML,objXSL,objFSO,strFile,strFileName,strXSL,strURL

 xmlGet=""

 iflen(trim(Request.form("fqdn")))>1then

strURL="http://www.domainbank.net/whoisresults_gen.cfm?show=1"

'WhoIS的地址

SetobjXML=CreateObject("Microsoft.XMLHTTP")'创建MS的XMLHTTP组件

stra="submit=submit&fqdn="&trim(Request.form("fqdn"))

objXML.Open"post",strURL,false

objXML.setrequestheader"content-length",len(stra)

objXML.setrequestheader"content-type","application/x-www-form-urlencoded"

objXML.sendstra'发送信息到WhoIs;

xmlGet=objXML.responseText'取得域名返回的信息

SetobjXML=Nothing

 endif

 response.writexmlGet'返回结果给客户端

%>


In the above process, we can find that our own web of ASP programs in fact only play a middle transfer, in practical applications, you can omit the middle layer, using VBScript through XMLHTTP directly to the WHOIS to send and receive data. However, this may be because the "access to data resources through (other) domain" in IE is disabled (the default) caused by insufficient permissions to cause the failure to execute, so the method of eliminating ASP middle tier is not very common.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.