Fully Qualified Domain Name(DNS)

Gopesh9
Posted by Gopesh9 under ASP.NET category on | Points: 40 | Views : 1372
<%@ Page Language="c#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Net" %>
<html>
<title>Performing a DNS Lookup </title>
<head>
<script language="c#" runat="server">
void Btn_Click(Object sender,EventArgs e) {
try
{
LblName.Text = "";
IPHostEntry GetIPHost = Dns.GetHostByName(TxtInput.Text);
LblValue.Text = "DNS LookUp as : " + "<Br>";
foreach(IPAddress ip in GetIPHost.AddressList)
{
long HostIpaddress = ip.Address;
LblValue.Text += HostIpaddress.ToString() + " -- ";
LblValue.Text += ip.ToString() + "<Br>";

}
LblHostName.Text = "Host Name is: " + GetIPHost.HostName;
}catch(Exception ex){
LblValue.Text = "<font color=red>Error:" + ex.Message;
}
}

</script>
</head>
<body>
<h3><font face="Verdana">DNS lookup for a particular Fully Qualified Domain Name.</font></h3>
<form runat="server">
Please enter Fully qualified Domain name:
<asp:TextBox id="TxtInput" runat="server" value="www.google.com" /><br />
<asp:Button id="BtnCheck" Text="Click Me" onclick="BtnCheck_Click" runat="server" /><br />
<br />
<asp:Label id="LblValue" runat="server" /><br />
<asp:Label id="LblHostName" runat="server" />
</form>
</body>
</html>

Comments or Responses

Login to post response