在代理后面找到IP地址 [英] Finding ip address behind proxy

查看:78
本文介绍了在代理后面找到IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来获取客户端系统的IP地址,但我仍在获取代理服务器的IP地址

I am using following Code for getting Ipaddress of client system but i am still getting ipaddress of Proxy server

Dim ip As String = String.Empty
      ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
      If Not String.IsNullOrEmpty(ip) Then
          Dim ipRange As String() = ip.Split(","c)
          Dim le As Integer = ipRange.Length - 1
          Dim trueIP As String = ipRange(le)
      Else
          ip = Request.ServerVariables("REMOTE_ADDR")
      End If
      Return ip

推荐答案

从ASP调用代码时,很难获得过去的代理地址.NET,因为某些代理不遵守规则.但是,如果代理服务器遵守规则并传递其转发流量的IP地址数据,则可以使用以下解决方案:

http://stackoverflow.com/Questions/2577496/how-can-i-get-the-clients-ip-address-in-asp-net-mvc [
Getting past proxy addresses can be difficult when calling the code from ASP.NET, since some proxies don''t play by the rules. However, if you proxy servers play by the rules and pass on the IP address data they are forwarding the traffic for, you can use the following solution:

http://stackoverflow.com/questions/2577496/how-can-i-get-the-clients-ip-address-in-asp-net-mvc[^]

I believe the actual answer you are looking for is the second most popular one. It walks you through how to access X_FORWARDED_FOR, which should give you the original IP address, along with every forwarded IP address.


使用以下代码,您将获得所有结果
You will get all results by using following code
For Each x In Request.ServerVariables
           Response.Write(x & ":" & Request.ServerVariables(x) & " </BR>  ")
       Next



您检查结果&使用以下代码获取Ipaddress



You check the results & using the following code for getting Ipaddress

Request.ServerVariables("YOUR RESULTS")


试试这个

Try this

Dim sysHost As [String] = System.Net.Dns.GetHostName()
Dim sysIP As [String] = System.Net.Dns.GetHostEntry(sysHost).AddressList(0).ToString(>


这篇关于在代理后面找到IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆