Invalid UserHostAddress

Today we’ve faced a weird problem.

While we are debugging noticed that we can not get the IPv4 address of the requester. Instead we were getting IPv6.

string userHostAddress = HttpContext.Current.Request.UserHostAddress; 

This code returns  “::1” instead of “127.0.0.1”.

After a little search this is about the Vista’s hosts file problem. And this is only a development issue for Vista systems.

Open your hosts file ( %WinDir%\System32\drivers\etc\hosts ) see the entry “::1    localhost”.  Feel free to remove line or comment the line with #.

Happy codding…

Posts created 141

Leave a Reply

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top