8

What is the difference between Request.ServerVariables["REMOTE_ADDR"] and Request.UserHostAddress?

Are either of these variables considered unreliable with respect to IP Address spoofing?

theycallmemorty
  • 12,515
  • 14
  • 51
  • 71
  • possible duplicate of [What is the difference between Request.UserHostAddress and Request.ServerVariables\["REMOTE\_ADDR"\].ToString()](http://stackoverflow.com/questions/13994582/what-is-the-difference-between-request-userhostaddress-and-request-servervariabl) – Michael Freidgeim May 01 '14 at 05:02
  • @MichaelFreidgeim considering I asked this question in June 2011 and that question was asked in December 2012 I don't think this is a duplicate. – theycallmemorty May 02 '14 at 19:47

2 Answers2

7

The .ServerVariables is provided for compatibility with the old ASP method for getting that information. Most of the information provided through that is now provided through separate properties.

Robert Beaubien
  • 3,126
  • 4
  • 22
  • 29
  • Do you know anything about the reliablity of these variables? Is it easy for someone to 'fake' their IP Address? – theycallmemorty Jun 30 '11 at 16:00
  • I don't know about faking an IP address. I know things like the referrerUrl can be faked. It is the same facility as the old ServerVariables just remapped so if you could fake it before, I'm sure you can still mess with the values. – Robert Beaubien Jun 30 '11 at 16:40
6

They are the same, ServerVariables["REMOTE_ADDR"] was provided only for backwards compatibility with older Classic Asp codebases. You should prefer using Request.UserHostAddress.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928