Forum Discussion
Aniket_129589
Jul 09, 2013Nimbostratus
Get ClientIP Address Behind LoadBalancer
Hi,
I am facing an issue to capture the actual IP address of the customers. The Web application is developed in ASP.NET 2.0 version (IIS version is 6.0) and it is hosted in Windows 2003 server b...
Aniket_129589
Jul 27, 2013Nimbostratus
Thanks Kevin for your continuous help on this.
This is just to inform you that we are using the below piece of codes to track the customer IP addresses.
string _custIP = null;
_custIP = HttpContext.Current.Request.ServerVariables["HTTP_CLIENT_IP"];
if (String.IsNullOrEmpty(_custIP))
{
_custIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
}
if (String.IsNullOrEmpty(_custIP))
{
_custIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
Customer IP1 = _hrHttpRequest.ServerVariables["REMOTE_ADDR"];
Customer IP2 = _custIP ;
Customer IP3 = _hrHttpRequest.UserHostAddress.ToString() ;
Customer IP4 = _hrHttpRequest.ServerVariables["HTTP_X_FORWARDED_FOR"];
We are receiving public IPs from the first three variables (and all of the three variables are capturing same IP address) and receiving NULL value in the last variable.
We are having one business intelligence tool which captures the customer IP addresses from the network itself and the IP address mismatch is seen from there. Just for an example, our piece of code has captured a customer IP address as 86.1.65.146, however the tool has captured the same as 2.103.197.20, which seems to be correct.
Please could you advice.
Many Thanks and Regards,
Aniket Samanta
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects