获取客户端自己设置的本地IP地址

复制代码
private string GetClientIP()
 {
 
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
 
if (null == result || result == String.Empty)
{
 result
= HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
 }
 
if (null == result || result == String.Empty)
  {
result
= HttpContext.Current.Request.UserHostAddress;
 }
 
return result;

 }

复制代码

 

posted @   老虞  阅读(400)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示