Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2004, 02:16 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get Hostname from IP

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.


 
Old October 8th, 2004, 07:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

<%@ 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>


 
Old October 8th, 2004, 07:53 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?

 
Old October 11th, 2004, 09:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Did you press the submit button?






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get hostname from ip address? starnold C# 6 June 18th, 2007 10:41 AM
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
How to get IP address shankhan Classic ASP Databases 6 March 10th, 2005 04:18 PM
IP mani_he Beginning PHP 4 November 8th, 2004 09:53 PM
get hostname from IP cygnusx04 Classic ASP Basics 12 October 14th, 2004 02:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.