|
Subject:
|
Get Hostname from IP
|
|
Posted By:
|
bekim
|
Post Date:
|
10/8/2004 2:16:01 AM
|
I saw this question in Classic ASP but I want this answer in ASP.NET.
Get hostname from IP. Is there any way in ASP.NET to resolve a hostname from a given IP address? (in VB.NET)
Thank you.
|
|
Reply By:
|
stu9820
|
Reply Date:
|
10/8/2004 7:11:40 AM
|
<%@ Import Namespace="System.Net" %>
<Script runat="Server">
Sub Button_Click( s As Object, e As EventArgs ) Dim objIPHostEntry As IPHostEntry
objIPHostEntry = Dns.GetHostByAddress( txtIP.Text ) lblHostName.Text = objIPHostEntry.HostName End Sub
</Script>
<html> <head><title>Dns.aspx</title></head>
<form runat="Server">
<h2>Enter an IP Address:</h2>
<asp:TextBox id="txtIP" Runat="Server" />
<asp:Button Text="Submit!" OnClick="Button_Click" Runat="Server" />
<p> <asp:Label id="lblHostName" EnableViewState="False" Runat="Server" />
</form> </body> </html>
|
|
Reply By:
|
bekim
|
Reply Date:
|
10/8/2004 7:53:57 PM
|
Hello stu9820 Thanks for your reply. But when I tried out your code the label is blank. It doens't return the hostname of the IP address I entered. What could be wrong?
|
|
Reply By:
|
stu9820
|
Reply Date:
|
10/11/2004 9:38:34 AM
|
Did you press the submit button?
|