Here is code to get the IP Address For User Tracking

digitalpower

BANNED
Dec 16, 2008
303
70
In case you want to do some simple user tracking on your ASP.NET website, you can use this function to get the current user's IP address.

Code:
Public Shared Function GetIPAddress() As String
        Dim sIPAddress As String
        sIPAddress = HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FOR")
        If sIPAddress = "" Then
            sIPAddress = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
        End If
        Return sIPAddress
    End Function
 
Public Shared Function GimmeClientIP() as String
Return Request.UserHostAddress
End Function



Note: The Request.UserHostAddress return's the Client's IP. Works all the time for me :) :) :)
 
Note: The Request.UserHostAddress return's the Client's IP. Works all the time for me

The code by digitialpower gets the users real IP even if they are behind a proxy, your's will just get the proxy address:)

Nice going dp :)
 
here you have a php code for it.

PHP:
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '')
		{ 
 	   $sIP = $_SERVER['HTTP_X_FORWARDED_FOR']; 
 	   $sProxy = $_SERVER['REMOTE_ADDR']; 
 	   $sHost = @gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']); 
		}
		elseif ( isset( $_SERVER['REMOTE_ADDR'] ) )
		{ 
 	   $sIP = $_SERVER['REMOTE_ADDR']; 
 	   $sHost = @gethostbyaddr($_SERVER['REMOTE_ADDR']); 
		}
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock