Solve domain registration query with ASP

Source: Internet
Author: User
Tags object end ftp generator net domain name registration server port visual studio
Workaround One:

Domain name registration query is mainly through the WHOIS server to complete, currently more commonly used is rs.internic.net, through it can query the various international domain name is registered. The port of whois is usually 43. Using Winsock, you can simply implement this function in ASP
Unlike the Php/jsp,winsock feature, ASP is not built in, so a third party Winsock component must be used.
Here The example uses the Serverobjects Aspsock, the code annotation is more detailed, everybody can lift a three
Aspsock is not free, need $49, if need free everyone can encapsulate Winsock control in VB6
or download from this address for free
Xceed Winsock Library v1.1
Ftp://ftp.xceedsoft.com/pub/xceedwsl.exe
The main page of this component is
http://www.xceedsoft.com/

Whois.asp
-------------------------------------------
<%@ Language=vbscript%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<BODY>
<form action=whois.asp method=post>
Domain name:www<b>.</b> <input size=8 name=domainname value= "<% =request" DomainName "". <select name=ext> <option
Selected>com</option> <OPTION>net</OPTION> <OPTION>org</OPTION>
</SELECT>
<input class=input1 type=submit value= domain name Query name=submit>
</form>

<%
Dim strresult
If Request.ServerVariables ("request_method") = "POST" THEN
Dim strquery
' Get the domain name you want to query
Strquery=request ("domainname") & "." & Request ("ext")

Dim Objsock
' Create a Sock object
Set objsock=server.createobject ("Aspsock.conn")
' Set the WHOIS server to Rs.internic.net
Objsock.remotehost= "Rs.internic.net"
' Set WHOIS server port to 43
objsock.port=43
' Set timeout of 60 seconds for operation
Objsock.timeout=60
' Open connection with RemoteHost, return true to success
If Objsock.open Then
' Send query Writeln for VBCRLF end (Strquery & VBCRLF)
Objsock.writeln strquery
' Read the return value with a maximum length of 65535
Strresult=objsock.readbytesasstring (65535)
' Close the connection
Objsock.close
' Print the query results, you can do something about it
Response.Write "<b> Query results </b><br><textarea rows=10 cols=60>" & Strresult & "</ Textarea> "
End If
Set objsock=nothing

End If
%>

</BODY>
</HTML>

The use of Winsock can accomplish many things that ASP is not likely to accomplish, such as NetEase like real no refreshing chat room, we carefully study it

Method Two:

<%@ Language=vbscript%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<BODY>
<form action=whois.asp method=post>
Domain name:www<b>.</b> <input size=8 name=domainname value= "<% =request" DomainName "". <select name=ext>
<option selected>com</option>
<OPTION>net</OPTION>
<OPTION>org</OPTION>
<OPTION>com.cn</OPTION> <OPTION>net.cn</OPTION> <OPTION>org.cn</OPTION>
</SELECT>
<input class=input1 type=submit value= domain name Query name=submit>
</form>

<%
Dim strresult
If Request.ServerVariables ("request_method") = "POST" THEN
Dim strquery
' Get the domain name you want to query
Strquery=request ("domainname") & "." & Request ("ext")

Dim Objsock
' Create a Sock object
Set objsock=server.createobject ("Aspsock.conn")
' Set the WHOIS server to Rs.internic.net
Select Case Request ("ext")
Case "com", "net", "org"
Objsock.remotehost= "Rs.internic.net"
Gj=0
Case "com.cn", "net.cn", "org.cn"
Objsock.remotehost= "drop.cnnic.net.cn"
Gj=1
End Select
' Set WHOIS server port to 43
objsock.port=43
' Set timeout of 60 seconds for operation
Objsock.timeout=60
' Open connection with RemoteHost, return true to success
If Objsock.open Then
' Send query Writeln for VBCRLF end (Strquery & VBCRLF)
Objsock.writeln strquery
' Read the return value with a maximum length of 65535
Strresult=objsock.readbytesasstring (65535)
' Close the connection
Objsock.close
' Print the query results, you can do something about it
' Response.Write ' <b> query results </b><br><textarea rows=10 cols=60> "& Strresult &" </ Textarea> "
Select Case
Case "0"
Str1=inter (Strresult)
Response.Write str1
Response.Write "<b> Query results </b><br><textarea rows=10 cols=60>" & Strresult & "</ Textarea> "
Case "1"
Str1=cnnic (Strresult)
Response.Write str1
Response.Write "<b> Query results </b><br><textarea rows=10 cols=60>" & Strresult & "</ Textarea> "
End Select
End If
Set objsock=nothing

End If

function Inter (str)
If InStr (str, "No match") =0 then
Response.Write "Your domain name has been registered. "
Else
Response.Write "Your domain name is not registered. "
End If
End Function

function Cnnic (str)
If InStr (str, "%") =0 Then
Response.Write "Your domain name has been registered. "
Else
Response.Write "Your domain name is not registered. "
End If
End Function
%>


</BODY>
</HTML>



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.