Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get local IP address in Asp.net,

i Have used the below code

C#
string GetIP4Address()
    {
        string IP4Address = String.Empty;

       
        foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
        {
            if (IPA.AddressFamily.ToString() == "InterNetwork")
            {
                IP4Address = IPA.ToString();     
                break;
            }           
        }
        return IP4Address;
    }


this function returns 192.168.1.104

but when i place it in FTP server, then it is giving another IP: 10.10.122.147
so i want to get my local ip address(which is displaying in command pront by ipconfig command) in asp.net website which is in FTP server,

One demo URL where it is displaying : http://www.ipaddresslocation.org/[^]
Posted
Updated 22-Aug-11 19:56pm
v2

with a little search on this forum: how to assign public to private ip address[^]
 
Share this answer
 
TextBox1.Text = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).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