B
Bikky Kumar Rai
Guest
I have a requirement to show user(s) public ip address, in a Window Form.
i tried below line of code but it is not giving me the client ip:
1-
string ipv6 = string.Empty;
var host = Dns.GetHostEntry(GetCurrentLoogedInHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
{
ipv6 = ip.ToString();
}
}
return ipv6;
2-
string ipv4 = string.Empty;
var host = Dns.GetHostEntry(GetCurrentLoogedInHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
ipv4 = ip.ToString();
}
}
return ipv4;
--------------------------------------------------------------------------------------------------------------
Above code is not giving me the result as the Google or website 'whatismyip' showing. PFB snapshot for more details:
Please help me guys, to get the public IP.
Bikky Kumar
Continue reading...
i tried below line of code but it is not giving me the client ip:
1-
string ipv6 = string.Empty;
var host = Dns.GetHostEntry(GetCurrentLoogedInHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
{
ipv6 = ip.ToString();
}
}
return ipv6;
2-
string ipv4 = string.Empty;
var host = Dns.GetHostEntry(GetCurrentLoogedInHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
ipv4 = ip.ToString();
}
}
return ipv4;
--------------------------------------------------------------------------------------------------------------
Above code is not giving me the result as the Google or website 'whatismyip' showing. PFB snapshot for more details:
Please help me guys, to get the public IP.
Bikky Kumar
Continue reading...