Click here to Skip to main content
16,020,459 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi we are developing an Application from which user fills the Form . And i need to Catch the IP Address of that system ... can any one help me
Posted
Comments
Mike Meinz 15-Nov-13 18:15pm    
What do you do about people that are behind routers using Network Address Translation? My former company of more than 30,000 employees uses NAT. Every one of those employees looks like the same IP Address to each web site they visit.

1 solution

Below is the code to get Public IP

C#
public string GetPublicIP()
{
    String direction = "";
    WebRequest request = WebRequest.Create("http://checkip.dyndns.org/");
    using (WebResponse response = request.GetResponse())
    using (StreamReader stream = new StreamReader(response.GetResponseStream()))
    {
        direction = stream.ReadToEnd();
    }

    //Search for the ip in the html
    int first = direction.IndexOf("Address: ") + 9;
    int last = direction.LastIndexOf("</body>");
    direction = direction.Substring(first, last - first);

    return direction;
}


http://stackoverflow.com/questions/1069103/how-to-get-my-own-ip-address-in-c[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900