日期:2014-05-18  浏览次数:20361 次

如何获得客户端IP地址信息
有些网站把显示自己IP地址和网络类型,比如:56.168.0.100 南阳 电信 
请问这应该如何实现?

------解决方案--------------------
非常好弄特别简单!到discuz里下载一下数据库和一个dll文件就可以实现你要的效果了!详细效果请见:http://www.52shw.com/lylb.aspx?id=257和http://www.52shw.com/newspl.aspx?id=9184
------解决方案--------------------
public static string GetIP()
{
string ip = "";

if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
}

return ip;
}
------解决方案--------------------
探讨
public static string GetIP()
{
string ip = "";

if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
}



------解决方案--------------------
这两个方法都行
非常好弄特别简单!到discuz里下载一下数据库和一个dll文件就可以实现你要的效果了!详细效果请见:http://www.52shw.com/lylb.aspx?id=257和http://www.52shw.com/newspl.aspx?id=9184
探讨
public static string GetIP()
{
string ip = "";

if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
}