Quantcast
Viewing all articles
Browse latest Browse all 20

Retrieving domain information through ASP.NET

There are many  domain checking websites available that gives all the information regarding domains. WhoIs is one of them. Following is a sample asp.net code that connects to one of WhoIs servers and retrieve information of a specific website.

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();
    }
}


Viewing all articles
Browse latest Browse all 20

Trending Articles