Performing a Reverse-DNS Lookup : Dns « Network « ASP.Net






Performing a Reverse-DNS Lookup

<%@ Page Language="c#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Net" %>
<html>
  <title>Performing a Reverse-DNS Lookup </title>
  <head>
    <script language="c#" runat="server">
       void BtnCheck_Click(Object sender,EventArgs e) {
        try
        {
            LblHostName.Text = "";
            IPAddress myIP = IPAddress.Parse(TxtInput.Text);
        
            IPHostEntry GetIPHost = Dns.GetHostByAddress(myIP);
            
            LblHostName.Text = "Host Name is: " + GetIPHost.HostName;  
        
        }catch(Exception ex){
          LblHostName.Text = "<font color=red>Error:" + ex.Message;
        }
        }

    </script>
  </head>
  <body>
    <h3><font face="Verdana"> Domain name for a particular IP address using a revere DNS 
        lookup.</font></h3>
    <form runat="server">
      Please enter IP address for a fully qualified domain name:
      <asp:TextBox id="TxtInput" runat="server" value="207.206.200.200" /><br />
      <asp:Button id="BtnCheck" Text="Click Me" onclick="BtnCheck_Click" runat="server" /><br />
      <br />
      <asp:Label id="LblHostName" runat="server" />
    </form>
  </body>
</html>

 








Related examples in the same category

1.DNS lookup for a particular Fully Qualified Domain Name