Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get visitor IP on load balancing machine using asp.net

We are having two load balancing server. In that we have hosted a asp.net 3.5 application right now we are using request userhostaddress to get visitor ip but it is giving load balancer ip instead of real ip. Can anyone have code for this.

like image 459
Jalpesh Vadgama Avatar asked Dec 23 '22 04:12

Jalpesh Vadgama


1 Answers

I think that you must search not only for HTTP_X_FORWARDED_FOR, but for all that, depent what your loading ballance using

Context.Request.ServerVariables[CheckAllBelowList]

"HTTP_X_COMING_FROM",
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED",
"HTTP_VIA",
"HTTP_COMING_FROM",
"HTTP_FORWARDED_FOR",
"HTTP_FORWARDED",
"HTTP_FROM",
"HTTP_PROXY_CONNECTION",
"HTTP_CLIENT_IP",
"CLIENT_IP",
"FORWARDED",

The return of one of that, is the actual Ip of you client, except if is other proxy, I also need to learn how some one can get this, to find the user that is behind 2-3 proxy's...

If you know any other, please tell me so.

like image 178
Aristos Avatar answered Feb 01 '23 22:02

Aristos