title: Get client IP on webserver (asp.net)
body: <p>I'm trying to obtain the client's IP on a http request to a page hosted on iis.</p>
  
  <p>I've looked into:</p>
  
  <p>1) <a href="http://forums.asp.net/t/1780050.aspx/1" rel="nofollow noreferrer">http://forums.asp.net/t/1780050.aspx/1</a></p>
  
  <p>2) <a href="https://stackoverflow.com/questions/527638/getting-the-client-ip-address-remote-addr-http-x-forwarded-for-what-else-coul">Getting the client IP address: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, what else could be useful?</a></p>
  
  <p>3) <a href="https://stackoverflow.com/questions/735350/how-to-get-a-users-client-ip-address-in-asp-net">How to get a user&#39;s client IP address in ASP.NET?</a></p>
  
  <p>4) <a href="https://stackoverflow.com/questions/4551660/client-ip-using-c-sharp">Client IP using C#</a></p>
  
  <p>As everyone said rightly, there is no fool proof way to get the client IP since the client can either be behind NAT or it can forge the IP address.</p>
  
  <p>However, i tried REMOTE_ADDR, HTTP_X_FORWARDED_FOR and UserHostAddress. They all are returning the server's IP instead of the client (the server is on a different machine than the client) i.e. either 127.0.0.1 or the server's LAN IP (192.168.xxx.xxx). I was expecting the correct response from HTTP_X_FORWARDED_FOR as it is immune to a proxy server.</p>
  
  <p>The puzzling thing is that when i host the page on the same machine as the client i.e. server is on localhost, i'm able to get the client ip (which is obviously equal to the server ip)</p>
  
  <p>Is there any setting in IIS that needs to be configured to get this working? or is it some other problem within the intranet?</p>