Pages

Monday, May 21, 2012

ASP.NET application not browsing on localhost

Recently I came across a problem where we hosted a new ASP.NET website on a freshly installed IIS (Windows 7). We were able to browse the application through the IP address. But when we tried to browse the application using the hostname or localhost, it didn't work (we reached the homepage but afterwards, all functions resulted in an asp.net error). We had the following scenario:

1. http://hostmachine/somesite (No)
2. http://localhost/somesite (No)
3. http://1.1.1.1/somesite (Yes)

After doing lots of googling (I mean binging :-), it turned out to be a potential bug where the DNS resolution didn't work for the loopback address. Microsoft claims that 127.0.0.1 is automatically resolved. But this is not the case and needs a fix. To fix this issue, go to C:\Windows\System32\drivers\etc and open the file hosts. Uncomment the following line:


# 127.0.0.1 localhost (remove #)


Now you can browse your application using localhost or hostname without any issue. I hope you find this article useful. Stay tuned for more.

No comments:

Post a Comment