web analytics

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

Options

davegate 143 - 921
@2016-01-22 12:13:43

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.

@2016-01-22 12:18:01

::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

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com