读书人

怎么获得客户端IP地址信息

发布时间: 2012-01-10 21:26:50 作者: rapoo

如何获得客户端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();
}


读书人网 >asp.net

热点推荐