Modified WHOIS Query procedure

Source: Internet
Author: User
Tags bool getstream tostring domain
Program <% @Page language= "C #"%>
<% @Import namespace= "System.Net"%>
<% @Import namespace= "System.Net.Sockets"%>
<% @Import namespace= "System.Text"%>
<% @Import namespace= "System.IO"%>
<% @Import namespace= "System.Collections"%>
<title>whois Query </title>
<link href= ". /inc/main.css "type=" Text/css "rel=" stylesheet ">
<script language= "C #" runat= "Server" >
void Doquery (Object sender, EventArgs e)
{
String Strdomain;
String strserver;
strserver = "whois.paycenter.com.cn";
Whois of the new network, the connection query faster, but not registered in the new network domain name may not be able to display detailed information
strserver = "66.150.5.140"; Whois.uwhois.com

if (txtdomain2.checked)
{strdomain = Txtdomain1.text+txtdomain2.text;}
Else
{
if (txtdomain3.checked)
{strdomain = Txtdomain1.text+txtdomain3.text;}
Else
{
if (txtdomain4.checked)
{strdomain = Txtdomain1.text+txtdomain4.text;}
Else
{
if (txtdomain5.checked)
{strdomain = Txtdomain1.text+txtdomain5.text;}
Else
{strdomain = Txtdomain1.text+txtdomain6.text;}
}
}
}


String strresponse;
BOOL bsuccess = Dowhoislookup (Strdomain, strserver, out strresponse);
if (bsuccess)
{
Txtresult.text = Strresponse;
}
Else
{
Txtresult.text = "Query failed!" Please try again. ";
}
}

BOOL Dowhoislookup (String strdomain, String strserver, out string strresponse)
{
Strresponse = "None";
BOOL bsuccess = false;

TcpClient TCPC = new TcpClient ();
Tcpc. Connect (Strserver, 43);
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 ();
while ( -1!= Sr. Peek ())
{
Strbuilder.append (Sr. ReadLine () + "<br>");
}
Tcpc. Close ();

bsuccess = true;
Strresponse = Strbuilder.tostring ();
}
catch (Exception e)
{
Strresponse = E.tostring ();
}

return bsuccess;
}
</script>
<body>

<form runat= "Server" >
Domain Name: Www.<asp:TextBox id= "txtDomain1" value= "" runat= "Server"/>
<asp:radiobutton id= "txtDomain2" groupname= "RadioGroup1" text= ". com" checked= "True" runat= "Server"/>
<asp:radiobutton id= "txtDomain3" groupname= "RadioGroup1" text= ". Net" runat= "Server"/>
<asp:radiobutton id= "TxtDomain4" groupname= "RadioGroup1" text= ". org" runat= "Server"/>
<asp:radiobutton id= "TxtDomain5" groupname= "RadioGroup1" text= ". Biz" runat= "Server"/>
<asp:radiobutton id= "txtDomain6" groupname= "RadioGroup1" text= ". CC" runat= "Server"/>
<asp:button id= "Btnquery" onclick= "doquery" text= "Query" runat= "Server"/>
<br><asp:label id= "Txtresult" forecolor= "#0000FF" class= "Body" runat= "server"/>
</form>
</body>


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.