在asp.net中获取所有访问者的IP地址 [英] get all visitor's ip address in asp.net
本文介绍了在asp.net中获取所有访问者的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
System.Web.HttpContext context = System.Web.HttpContext.Current;
string ipAddress = context.Request.ServerVariables [ HTTP_X_FORWARDED_FOR跨度>];
if (!string.IsNullOrEmpty(ipAddress))
{
string [] addresses = ipAddress.Split(' ,');
if (addresses.Length!= 0 )
{
返回地址[ 0 ];
}
}
return context.Request.ServerVariables [ REMOTE_ADDR];
}
http://www.c-sharpcorner.com/uploadfile/krishnasarala/find-client-ip-address-and-location-in-Asp-Net/ [ ^ ]
http://www.aspdotnet-suresh.com/2012/07/how-to-get-find-ip-address-of-client.html [ ^ ]
http://www.dotnetboss.com/2010/04/29/how-to-get-client-ip-address-using -asp-net-c / [ ^ ]
string ipaddress;
ipaddress = Request.ServerVariables [ HTTP_X_FORWARDED_FOR];
if (ipaddress == || ipaddress == null )
ipaddress = Request.ServerVariables [ < span class =code-string> REMOTE_ADDR];
或等价代码可以用vb写成
i have a website. I want to get all visitor's ip address in the moment. Please help me.
解决方案
System.Web.HttpContext context = System.Web.HttpContext.Current; string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (!string.IsNullOrEmpty(ipAddress)) { string[] addresses = ipAddress.Split(','); if (addresses.Length != 0) { return addresses[0]; } } return context.Request.ServerVariables["REMOTE_ADDR"]; }
http://www.c-sharpcorner.com/uploadfile/krishnasarala/find-client-ip-address-and-location-in-Asp-Net/[^]
http://www.aspdotnet-suresh.com/2012/07/how-to-get-find-ip-address-of-client.html[^]
http://www.dotnetboss.com/2010/04/29/how-to-get-client-ip-address-using-asp-net-c/[^]
string ipaddress; ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddress == "" || ipaddress == null) ipaddress = Request.ServerVariables["REMOTE_ADDR"];
or equavalent code can be written in vb
这篇关于在asp.net中获取所有访问者的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文