Convert Domain Name to I.P Address

A user asked me on the forums if it was possible to convert a domain name to an I.P. Address. The answer is quiet simple. Just use the System.Net.Dns class

C#


using System.Net;

protected void Page_Load(object sender, EventArgs e)

{

    foreach (IPAddress address in 

        Dns.GetHostAddresses("www.devcurry.com"))

    {  

        Response.Write(address.ToString());

    }

}



VB.NET


Imports System.Net

Protected Sub Page_Load(ByVal sender As Object, _

                     ByVal e As EventArgs)

    For Each address As IPAddress In 

    Dns.GetHostAddresses("www.devcurry.com")

        Response.Write(address.ToString())

    Next address

End Sub



Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

2 comments:

sanjith said...
This comment has been removed by the author.
sanjith said...

Informative blog really helpful for those who are looking for some programs to find the ip address of website ..I am not a techsavy so i usually find the ip address of any website using sites like Ip-Details.com here they will render domain host search tool which display the ip address of any website along with details like ip location ,country ,ISP address and so on ...