HttpContext.Current.Request.UserHostAddress returns ::1 on IIS 7.0 Options

davegate Posts: 182 Points: 894
Posted: Friday, January 22, 2016 12:13:43 PM

On IIS 6.0, if your application calls HttpContext.Current.Request.UserHostAddress, the result will "127.0.0.1", but the same on IIS 7.0, the result will be "::1".

if you open your hosts file ( %WinDir%\System32\drivers\etc\hosts ) it should have the entry "::1    localhost", it seems IIS 7 is favouring this address to the IPV4 address 127.0.0.1 (that should also be present).  If you really want "127.0.0.1" get returned then remove "::1    localhost" from your HOSTS file.

 

davegate Posts: 182 Points: 894
Posted: Friday, January 22, 2016 12:18:01 PM

::1 Localhost is the equivalent to 127.0.0.1 Localhost but using IPv6 protocol format , ::1 localhost is valid when Internet Protocol version 6 (IPv6) is implemented on a system.

IPv4 127.0.0.1
IPv6 ::1

"::" is an abbreviation for missing zeros, so this loopback entry really means

0000:0000:0000:0000:0000:0000:0000:0001 localhost

Users browsing this topic
Guest