Creating domain Name query system with ASP

Source: Internet
Author: User
Tags chr comments html form html page trim valid domain name server client
Query System | Domain Name Query

First, the principle:

The principle is very simple, domain name query is based on RFC 954 provided by the WHOIS protocol. In the implementation process, we access the NIC site's whois database server through our own Web server, query the WHOIS database for what we need, and then synthesize the page back to the client via ASP group.

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 Server in the ASP listening page to accept the request, use XMLHTTP to send Retrieval command to the WHOIS server-->whois database to perform query operations, Return results to our own Web server (HTML form) after the-->web server receives the content, the results are delivered to the client-> the client browser uses VBScript to filter out the unwanted portions of the HTML, picking out the WHOIS data to display.

Second, ASP XMLHTTP programming Brief:

1. Client HTML page:

<script language= "VBScript" >
Sub Submit1_onmouseup ' is triggered when clicking the ' Query ' button;
Dim Objxml, objxsl, Objfso,strfile, strFileName, Strxsl,strurl,theform
Set theform = Document.wordfind
window.status= "Retrieving Data ..."
Strurl= "Dns.asp"
Set Objxml = CreateObject ("Microsoft.XMLHTTP") ' creates the XMLHTTP component of MS;
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.send stra ' Send message
Xmlget = Objxml.responsetext ' Wait a moment, get the result of the server-side return;
If InStr (1,xmlget, "this are not a valid. com. net. org. info or. biz domain Name", 1) <1 and Len (Trim (xmlget)) >100 Then
If InStr (1,xmlget, "This domain is available", 1) <1 Then
If InStr (1,xmlget, "Registrant:", 1) Then
StrFind1 =instr (1,xmlget, "Registrant:", 1)
Else
StrFind1 = InStr (1,xmlget, "<pre> <font face=" "Verdana, Arial", 1) +65

strfind2 = InStr (1,xmlget, " ", 1)
Strfind4=strfind2-strfind1
SHTML = Mid (Xmlget,strfind1,strfind4)
theform.comments.value= "Query results:" +CHR (13) + Chr (a) +shtml
window.status= Query result: The domain name is already occupied
else
theform.comments.value= "Congratulations, this domain is available!" "
window.status=" Query results: The domain name is still available! "
End If
Else
theform.comments.value=" is not a valid international top-level domain name! Please enter an international domain name that ends with (. com. net. org. info or.), such as sun.com "
window.status=", an invalid international top-level domain name! Please enter an international domain name that ends with (. com. net. org. info or.), such as cctv.com "
End If
Set objxml = Nothing
End Sub
p>

XMLHTTP Domain name Query Chapter


Please enter a domain name:

form>


2, server-side ASP program:

<%dim Xmlget,objxml, objxsl, Objfso,strfile, strFileName, Strxsl,strurl
Xmlget= ""
If Len (Trim (Request.Form ("FQDN))") > 1 Then
Strurl= "Http://www.domainbank.net/whoisresults_gen.cfm?show=1"
' The address of the WHOIS server
Set Objxml = CreateObject ("Microsoft.XMLHTTP") ' creates the XMLHTTP component of MS

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.send stra ' send information to whois database server;


Xmlget = Objxml.responsetext ' Get the information returned by the domain name server
Set Objxml = Nothing
End If
Response.Write Xmlget ' return results to client
%>

In the above process, we can find that the ASP program in our own Web server only acts as an intermediary, in practical applications, it can also omit this middle layer, using VBScript to send and receive data directly to the WHOIS database through XMLHTTP. 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.

This program runs on the IIS5.0 and IE6.0 based on the Windows2000 platform. The actual use of the process, you can copy the above code to their own web page, after a simple page editing, you can add in their own pages in the page without refreshing the domain name query function, at first look, it is really a bit like a professional domain name registrar services provided by the website.



Related Article

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.