Asp. NET Domain Name query system
Last Update:2017-02-28
Source: Internet
Author: User
asp.net| Query system <% @Page language= "C #"%>
<% @Import namespace= "System.Net.Sockets"%>
<% @Import namespace= "System.Text"%>
<% @Import namespace= "System.IO"%>
<title>.com/.net/.org/.cn domain whois information inquiry </title>
<meta name= "keywords" content= "com,.net,.org,.cn domain whois information query" >
<meta name= "generator" content= "com/.net/.org,.cn domain whois information query" >
<meta name= "description" content= "com/.net/.org,.cn domain whois information query" >
<style>
<!--
body,input{
Font-family:tahoma, Verdana; Color: #004080; font-size:12px
}
a:link,a:visited{
Text-decoration:none; Color: #004080
}
-->
</style>
<body>
<form id= "Fmquery" runat= "Server" >
Domain name to query:
Www.<asp:TextBox id= "Txtdomain" width= value= "aspxboy.com" runat= "Server"/>
<asp:button id= "Btnquery" onclick= "Btn_click"
text= "Query!" runat= "Server"/> (can only query.) com/.net/. org/. Cn domain whois information) <a href = "whoiscode.htm" title= "View The source code here!" > Source code is here </a>
<br><asp:label id= "Lblresult" runat= "Server"/>
</form>
</body>
<script language= "C #" runat= "Server" >
void Btn_click (Object sender, EventArgs e)
{
String strserver;
String strdomain = Txtdomain.text;
String strservercom = "whois.networksolutions.com";
String STRSERVERCN = "whois.cnnic.net.cn";
String strresponse;
string[] Arrdomain = Strdomain.split ('. ');
if (arrdomain[1). ToUpper () = = "CN")
{
STRSERVER=STRSERVERCN;
}
Else
{
strserver=strservercom;
}
BOOL blsuccess = iswhosissuccess (Strdomain, strserver, out strresponse);
if (blsuccess)
{
Lblresult.text = Strresponse;
}
Else
{
Lblresult.text = "Find failed ...";
}
}
BOOL Iswhosissuccess (String strdomain, String strserver,
Out String strresponse)
{
Strresponse = "None";
BOOL blsuccess = false;
TcpClient TCPC = new TcpClient ();
Try
{
Tcpc. Connect (Strserver, 43);
}
catch (SocketException ex)
{
Strresponse = "Cannot connect to this Whois server, please try again later." ";
return false;
}
Strdomain + = "\ r \ n";
byte[] Arrdomain = Encoding.UTF8.GetBytes (Strdomain.tochararray ());
Try
{
Stream s = tcpc. GetStream ();
S.write (arrdomain, 0, strdomain.length);
StreamReader sr = new StreamReader (TCPC. GetStream (), Encoding.UTF8);
StringBuilder Strbuilder = new StringBuilder ();
string strLine = null;
while (null!= (StrLine = Sr.) ReadLine ()))
{
Strbuilder.append (strline+ "<br>");
}
Tcpc. Close ();
Blsuccess = true;
String my= "Go to Huobazi ' s website:<a href=\" http://www.aspxboy.com\ "title=\". NET boy community \ ">www.AspxBoy.Com</a><br>";
Strresponse = strbuilder.tostring () +my; }
catch (Exception e)
{
Strresponse = E.tostring ();
}
return blsuccess;
}
</script>