ASP.Net/Network/Dns
DNS lookup for a particular Fully Qualified Domain Name
<%@ 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 BtnCheck_Click(Object sender,EventArgs e) {
try
{
LblHostName.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.ru" /><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>
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>