How to get Ip Address in a .NET application


In this article, I will explain how to get the Ip address of the client in a .NET application.

Get IP Address



When we are work with web application , client side is a very important factor, in dynamic webapplication it is necessary to know your client


Here I give an example to get Client IP Address

//create host object

string cname = System.Net.Dns.GetHostName();

//get the address into cid string variable

string cid = System.Net.Dns.GetHostAddresses(cname).GetValue(0).ToString();

//printing the values

Response.Write(cid);


Related Articles

More articles: IP address Get IP address

Comments

Author: Sabu C Alex06 Oct 2010 Member Level: Gold   Points : 0

Thank you shubhang sahai mathur

your code helped me a lot

Sabu Alex



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: