Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I want to know how to get IP Address.
Please Help me... :((
Posted

To Find IP Address
you can use this code

first up all include System.Net namespace and then write the given code

C#
string str = Environment.MachineName.ToString(); // MachineName use to get the name of your System

        IPHostEntry ipe = Dns.GetHostByName(str); // IPHostEntry Provide a Contaner Class for internet host address
        Console.WriteLine("Your IP address is : ");
        for (int i = 0; i < ipe.AddressList.Length; i++)
        {
            Console.WriteLine(ipe.AddressList[i]);
        }
 
Share this answer
 
 
Share this answer
 
v2
In asp.net you can get the ip address by it ->
string ip = Request.Params["REMOTE_ADDR"].ToString();
 
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