c#获取真实IP和代理IP
2009-11-25 15:34
405 查看
获取真实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;
}
获取代理IP
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;
}
Appendix
what proxy server are you using? if you are using ISA, take a look at:
http://www.isaserver.org/articles/Configuring_a_ISP_Colocated_WebSMTPISA_Server.html
basically, you need to set the proxy server in transparent mode
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;
}
获取代理IP
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;
}
Appendix
what proxy server are you using? if you are using ISA, take a look at:
http://www.isaserver.org/articles/Configuring_a_ISP_Colocated_WebSMTPISA_Server.html
basically, you need to set the proxy server in transparent mode
相关文章推荐
- c#获取真实IP和代理IP
- 转】c#如何获取真实IP和代理IP
- c#获取真实IP和代理IP
- 获取真实IP和代理IP (asp.net C#)
- c#获取真实IP和代理IP
- .net(c#)获取客户端真实IP,非代理
- (转)c#获取真实IP和代理IP
- 如何突破代理获取客户的真实IP
- C#获取浏览者IP真实地址
- java实现穿透代理获取客户端真实ip .
- 多层nginx代理tomcat获取客户端真实ip
- 多重代理时如何防止伪造X-Forwarded-For且获取真实IP
- 微信h5 在有代理的情况下,获取客户端的真实ip
- C#获取真实的客户端IP地址,包括内网代理
- nginx代理web,后端无法获取用户真实IP
- nginx反向代理后应用程序如何获取客户端真实IP?
- nginx反向代理后应用程序如何获取客户端真实IP?
- nginx反向代理后应用程序如何获取客户端真实IP?
- Nginx反向代理下IIS获取真实IP
- php获取客户端真实IP 防止代理和作弊