| 订阅 | 在线投稿
分享
 
 
 

c#获取真实IP和代理IP

来源:互联网  宽屏版  评论
2008-12-13 08:24:18

获取真实IPview plaincopy to clipboardprint?

public static string GetRealIP()

{

string ip;

try

{

HttpRequest request = HttpContext.Current.Request;

if (request.ServerVariables["HTTP_VIA"] != null)

{

ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();

}

else

{

ip = request.UserHostAddress;

}

}

catch (Exception e)

{

throw e;

}

return ip;

}

public static string GetRealIP()

{

string ip;

try

{

HttpRequest request = HttpContext.Current.Request;

if (request.ServerVariables["HTTP_VIA"] != null)

{

ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();

}

else

{

ip = request.UserHostAddress;

}

}

catch (Exception e)

{

throw e;

}

return ip;

}获取代理IPview plaincopy to clipboardprint?

public static string GetViaIP()

{

string viaIp = null;

try

{

HttpRequest request = HttpContext.Current.Request;

if (request.ServerVariables["HTTP_VIA"] != null)

{

viaIp = request.UserHostAddress;

}

}

catch (Exception e)

{

throw e;

}

return viaIp;

获取真实IPview plaincopy to clipboardprint? public static string GetRealIP() { string ip; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["HTTP_VIA"] != null) { ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); } else { ip = request.UserHostAddress; } } catch (Exception e) { throw e; } return ip; } public static string GetRealIP() { string ip; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["HTTP_VIA"] != null) { ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); } else { ip = request.UserHostAddress; } } catch (Exception e) { throw e; } return ip; }获取代理IPview plaincopy to clipboardprint? public static string GetViaIP() { string viaIp = null; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["HTTP_VIA"] != null) { viaIp = request.UserHostAddress; } } catch (Exception e) { throw e; } return viaIp;
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有