Need to run a fully Featured Dynamic DNS Service?
Now You Can With - - Our Award Winning Dynamic DNS (DDNS) Server Suite!!!
Perfect for IP cameras or DVR's. It's never been easier to run your own DDNS service.

Looking for free Dynamic DNS (DDNS) services? Please use our free DDNS service(s) at http://access.camera



Go Back
HTTP_X_FORWARDED_FOR may return multiple IP addresses
 
HTTP_X_FORWARDED_FOR can sometimes return a comma delimited list of IP addresses. Please feel free to use this code in any way you like.

Example IP's
24.116.98.21, 24.116.98.23, 24.113.65.23

The last IP in list should be the correct IP for the user.
The first IP should be the address of the Proxy.
I have included code samples for both options.

Classic ASP example. (Correctly detecting a users IP)
VBScript Code:
MyIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If MyIP = "" or Trim(LCase(MyIP)) = "unknown" Then
MyIP = Request.ServerVariables("REMOTE_ADDR")
End If

IsMulti = InStr(1, MyIP, ",", 1)

'Use one or the other not both
'Gets the first IP in list
If IsMulti > 0 Then
strArray = Split(MyIP, ",")
MyIP = strArray(0)
MyIP = Trim(MyIP)
End If

'Gets the last IP in list
If IsMulti > 0 Then
strArray = Split(MyIP, ",")
For iCntr = 0 To UBound(strArray)
MyIP = strArray(iCntr)
Next
MyIP = Trim(MyIP)
End If


In C# (This sample gets the first IP in the list)
C# Code:
String MyIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    //Trim and lowercase IP if not null
    if (MyIP != null)
    {
    MyIP = MyIP.ToLower();
    MyIP = MyIP.Trim();
    }
   
    //If IP is null use different detection method. Else pull the correct IP from list.
    if ((MyIP == null) || (MyIP == "unknown"))
    {
        MyIP = Request.ServerVariables["REMOTE_ADDR"];
    }
    else if (MyIP.IndexOf(",") != -1){
        string[] IPs = MyIP.Split(',');
        // First IP MyIP = IPs.GetValue(0).ToString().Trim();

        MyIP = IPs.GetValue(IPs.Length -1).ToString().Trim();
    }

As always if you need any help, please feel free to ask.
i dreamed my husband cheated on me beautiful women cheat online
viagra ár open viagra szedése
ibuprofen wirkung link ibuprofen 400
nolvadex achat nolvadex pct nolvadex
cozaar notice nufactor.com cozaar eureka
voltaren gel price gpatterson.com voltaren 50


Go Back