本文介绍了获取客户端本地计算机IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个MVC Web应用程序,此应用程序托管在公共服务器上。
我需要获得在他们的机器上使用这个网站的每个用户的本地机器Ipaddress(不是网络公共IP)...
我怎么能实现这个目标?..
谢谢
Magesh.M
Hi,
I have a MVC Web Application, This Application is hosted in a public server.
I needs to get the local machine Ipaddress(not the network public ip) of every user who uses this site in their machines...
How can i achieve this ?..
Thanks
Magesh.M
推荐答案
public static string GetIPAddress()
{
IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIP = ip.ToString();
}
}
return localIP;
}
这篇关于获取客户端本地计算机IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!