Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write asp with C # Software

Shulou Source: shulou.com Published: 2022-06-02 09:02:36 10月04日 Update

This article will explain in detail how to write asp in C# software. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Source code:

Void doQuery (Object sender, EventArgs e)

{

String strDomain = txtDomain.Text

Char [] chSplit = {'.'}

String [] arrDomain = strDomain.Split (chSplit)

Int nLength = arrDomain [1] .length

Hashtable table = new Hashtable ()

Table.Add ("de", "whois.denic.de")

Table.Add ("be", "whois.dns.be")

Table.Add ("gov", "whois.nic.gov")

Table.Add ("mil", "whois.nic.mil")

String strServer; / / define whois server

/ / if the domainname's end is cn then the server is cnnic

Otherwise is networksolutions

If (arrDomain [arrDomain.Length-1] = = "cn")

{

StrServer = "159.226.6.139"

}

Else

{

StrServer = "whois.networksolutions.com"

}

If (table.ContainsKey (arrDomain [1]))

{

StrServer = table [arrDomain] [1]] .ToString ()

}

Else if (nLength = = 2)

{

/ / 2-letter TLD's always default to RIPE in Europe

StrServer = "whois.ripe.net"

}

String strResponse

Bool bSuccess = DoWhoisLookup (strDomain, strServer, out strResponse)

If (bSuccess)

{

TxtResult.Text = strResponse

}

Else

{

TxtResult.Text = "Lookup failed"

}

}

Bool DoWhoisLookup (String strDomain, String strServer, out String strResponse)

{

StrResponse = "none"

Bool bSuccess = false

TCPClient tcpc = new TCPClient ()

If (0 = tcpc.Connect (strServer, 43))

{

StrDomain + = "\ r\ n"

Byte [] arrDomain = Encoding.ASCII.GetBytes (strDomain.ToCharArray ())

Try

{

Stream s = tcpc.GetStream ()

S.Write (arrDomain, 0, strDomain.Length)

StreamReader sr = new StreamReader (tcpc.GetStream (), Encoding.ASCII)

StringBuilder strBuilder = new StringBuilder ()

While (- 1! = sr.Peek ())

{

StrBuilder.Append (sr.ReadLine () + "")

}

Tcpc.Close ()

BSuccess = true

StrResponse = strBuilder.ToString ()

}

Catch (Exception e)

{

StrResponse = e.ToString ()

}

Return bSuccess

}

Else

{

StrResponse = "Could not connect to Whois server"

Return false

}

Return false

}

Domain name: WWW.

This is the end of the article on "how to write asp in C# Software". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Articles software more good practical content articles source code knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info MariaDB OPPO Reno Shulou Technology