C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ADO.NET »

Hostname to ip address converter


Posted Date: 23 Sep 2009    Resource Type: Code Snippets    Category: ADO.NET
Author: Kritika YadavMember Level: Gold    
Rating: 1 out of 5Points: 3



Hostname to ip address converter



If you know the hostname then you can easily retrieve the ip address of the same from domain name serve.

Here is the code to do this.


string hostname = "www.niksgaur.blogspot.com";
IPAddress[] addresslist = Dns.GetHostAddresses(hostname);

foreach (IPAddress theaddress in addresslist)
{
Response.Write(theaddress.ToString()) + "
;
}


and please don't forgate to use System.Net name space otherwise it will give an error in IPAddress class.



Responses

Author: Prashant Mishra    30 Sep 2009Member Level: Bronze   Points : 0
good kriti.....you have solved my big prob....


Author: harjit    01 Oct 2009Member Level: Bronze   Points : 2
Imports System.Net
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim hostname As IPHostEntry = Dns.GetHostByName(TextBox1.Text)
Dim ip As IPAddress() = hostname.AddressList
TextBox2.Text = ip(0).ToString()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class


Author: Nitin     02 Oct 2009Member Level: Bronze   Points : 0
Thanks :)


Author: Kritika Yadav    04 Oct 2009Member Level: Gold   Points : 0
hello harjit,

why you write this code here.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
IPAddress  .  Hostname  .  Converter  .  Address  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Stored Procedure demo ADO.NET Example
Previous Resource: Restricting the Webpart Manager Displaymodes based on user roles
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use