Asp. NET Domain Name query system

Source: Internet
Author: User
Tags bool getstream tostring net domain
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>


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.