Fetching domain whois information using asp.net
There are several domain whois checking websites available today. For example, who.is and domaintools.com are broadly used. It is very easy to develop such web application of your own. All you need to query the whois server for a domain in question. Here is the sample code, that fetches the whois information associated with the domain provided in the query.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Sockets;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string domainname = Request.QueryString["domain"].ToString();
TcpClient objTCPC = new TcpClient();
objTCPC.Connect(“whois.enom.com”, 43);
string strDomain = domainname;// +”\\r\\n”;
byte[] arrDomain = Encoding.ASCII.GetBytes(strDomain);
Stream objStream = objTCPC.GetStream();
objStream.Write(arrDomain, 0, strDomain.Length);
StreamReader objSr = new StreamReader(objTCPC.GetStream(),Encoding.ASCII);
string strServerResponse = objSr.ReadToEnd();
strServerResponse = Regex.Replace(strServerResponse, “\n”, “<br>”);
Response.Write(strServerResponse);
objTCPC.Close();
}
}
Above code will query the whois server whois.enom.com to get the whois information of ask4asp.net. You can use any whois servers. I am listing some of them below.
whois.arin.net
whois.ripe.net
whois.apnic.net
whois.lacnic.net
whois.afrinic.net
whois.enom.com, etc.















