.Net获取IP地址-创新互联
来自森大科技官方博客
http://www.cnsendblog.com/index.php/?p=292
GPS平台、网站建设、软件开发、系统运维,找森大网络科技!
http://cnsendnet.taobao.com
1.获取本机IP
2.获取网页客户端IP
///
/// 获取IPv4地址
///
///
public static string GetIP4Address(HttpRequest request = null)
{
Func f = e => e.AddressFamily.ToString() == "InterNetwork";
IPAddress ipa = Dns.GetHostAddresses((request ?? HttpContext.Current.Request).UserHostAddress).FirstOrDefault(f)
?? Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault(f);
if (ipa != null)
{
return ipa.ToString();
}
return HttpContext.Current.Request.UserHostAddress;
}
来自森大科技官方博客
http://www.cnsendblog.com/index.php/?p=292
GPS平台、网站建设、软件开发、系统运维,找森大网络科技!
http://cnsendnet.taobao.com
本文标题:.Net获取IP地址-创新互联
标题路径:http://cdiso.cn/article/eeedj.html