I am trying to get client ID with vb.net. My code is as under :
Partial Class foo
Inherits System.Web.UI.Page
Private ipv4 As New clsIPv4
Dim ref As String = 0
Dim client_ip As String
client_ip = Request.UserHostAddress()
Dim myHost As String = System.Net.Dns.GetHostName()
client_ip = ipv4.ResolveAddress(myHost)
This code is returning me list of ip adresses (i.e 182.50.130.143;118.139.172.1;118.139.172.2;118.139.172.3;118.139.172.4;118.139.172.5;118.139.172.6;118.139.172.7;118.139.172.8;118.139.172.9;118.139.172.10;118.139.172.11;118.139.172.12;118.139.172.13;118.139.172.14;118.139.172.15;118.139.172.16;118.139.172.17;118.139.172.18;118.139.172.19;118.139.172.20;118.139.172.21;118.139.172.22;118.139.172.23;118.139.172.24;118.139.172.25;118.139.172.26;118).
Please guide where I am wrong
If you are using ASP.NET, you can use: Request.UserHostAddress
to get your client IP address.
But if you are using a windows application to get local IP address, in fact you may receive multiple IP addresses! In this case, if you want to get a specific address which you know the netid part of the IP address you can compare all IP addresses with a corresponding netid address.
This worked perfectly for me
System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With