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

前端 未结 4 2010
北海茫月
北海茫月 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 03:54

    According to this, the format of X-Forwarded-For HTTP header is:

    X-Forwarded-For: client1, proxy1, proxy2, ...
    

    So the IP address of the client that you want should be the first one in the list

提交回复
热议问题