Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using following Code for getting Ipaddress of client system but i am still getting ipaddress of Proxy server

VB
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
Posted
Comments
RDBurmon 13-Jun-12 9:34am    
Thanks Everyone who replied to this thread , So Bhargav, I think you have got enough responses and you should be able to mark it as your answer and close the thread. Please do so.

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.
 
Share this answer
 
Comments
Bhargav1985 13-Jun-12 0:31am    
For X_FORWARDED_FOR i am getting null value
You will get all results by using following code
VB
For Each x In Request.ServerVariables
           Response.Write(x & ":" & Request.ServerVariables(x) & " </BR>  ")
       Next


You check the results & using the following code for getting Ipaddress
VB
Request.ServerVariables("YOUR RESULTS")
 
Share this answer
 
Try this

Dim sysHost As [String] = System.Net.Dns.GetHostName()
Dim sysIP As [String] = System.Net.Dns.GetHostEntry(sysHost).AddressList(0).ToString(>
 
Share this answer
 
Comments
Bhargav1985 12-Jun-12 8:19am    
i tried the code. I am geting the same Proxy address
Try this one

string ipaddress=Request.UserHostAddress

and Dont forgot to add this header file

using System.Net;
 
Share this answer
 
Comments
Bhargav1985 13-Jun-12 0:30am    
i tried this part of the code still I am geting the same Proxy address

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900