How do I get the correct IP from HTTP_X_FORWARDED_FOR if it contains multiple IP Addresses?

前端 未结 4 2011
北海茫月
北海茫月 2020-11-29 03:29

If Request.ServerVariables[\"HTTP_X_FORWARDED_FOR\"] returns multiple ip\'s, which one do I take and how would I do it in c#? It is my understanding that if it is blank or

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 04:02

    I asked some time ago a very similar question.

    Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful?

    As correctly pointed out, you can take the first value considering it to be the client's IP address. But it may as well be company gateway IP.

    And anonymous proxies will wipe out information in this header anyway, so it is useful but not reliable.

提交回复
热议问题