Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
 
private string ip()
    {
        string strHostName = "";
        strHostName = System.Net.Dns.GetHostName();
 
        IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
 
        IPAddress[] addr = ipEntry.AddressList;
 
        return addr[addr.Length - 1].ToString();
    }
 
 

m using this code but it return
 
"2001Blush | :O :4137:9e76:caa:325e:3f57:fe9b" somthing like this
 
So what can i do for to get correct IP Address of the system
Posted 29-Nov-12 0:54am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

That looks like an IPv6 format address[^].
  Permalink  
Comments
Dev_ashish at 29-Nov-12 6:17am
   
Thanks Richard MacCutchan for ur response but my problem create when m log on from diff computer's it return same answer..
Richard MacCutchan at 29-Nov-12 6:34am
   
What do you expect? It gets the local hostname and returns the IP address in either IPv4 or IPv6 format, according to which type is in use.
Dev_ashish at 29-Nov-12 6:38am
   
i want when m log in from different host then it should return diff IP Address...
Richard MacCutchan at 29-Nov-12 6:49am
   
It does not matter where you login from you are only asking for the address of your local machine.

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



Advertise | Privacy | Mobile
Web02 | 2.8.150326.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100