Friday, November 13, 2009

ASP.NET Development Server shows error page for localhost

The operating system on your computer is getting slower and slower and all the old software clogging it eventually forces you to reinstall everything from scratch. Does it sound familiar to you? I bet it does!

Even though I like the feel of a fresh installation, I personally hate spending so much time actually doing it. Sadly enough, in my case this literally means spending an entire day carefully satisfying my meticulous thinking to have even the slightest detail configured exactly the way I like.

Nevertheless the time has come and I had to do it again. I did not expect any major problems as I was mainly installing the software and drivers I have already been using for some time now and they have been working very well. In the beginning everything went on pretty smooth, but then, there comes the Murphy’s laws. I arrived at a problem.

After installing the Visual Studio 2008 with Service Pack 1 together with the SQL Server I wanted to test it on some of my projects. Basically that everything builds, runs and works fine. The problem came when I tested the ASP.NET projects, where the ASP.NET Development Server was being used.

As usual, hitting the F5 or CTRL+F5 in Visual Studio started the server on a random port number and fireed up the Internet Explorer pointing it to http://localhost:someportnumber/somedirectory. All of this happened, but then, oops - the page cannot be displayed!

I have been trying everything, but nothing seemed to work. I had no antivirus software installed nor used any other than Vista’s standard firewall. The problem appeared in IE as well as in FireFox. I could not find the cause.

A few hours later, I found out, that the page will display itself, if I use instead of the localhost. That led me to more googling as well as finally getting on the right track.

In the end, the best fix for this problem I have found, is to make a modification to the hosts file, located under windows\system32\drivers\etc directory. There I found this line:

::1          localhost

By adding one more colon, I changed it to:

:::1         localhost

And yes! That made all the difference in the world! The localhost started working perfectly in both browsers.

I am not sure, why I have not come across this problem earlier as I was also using Visual Studio 2008 and Vista on my previous installation, but this is what I did to fix it. If you are having the same problem and eventually found your way to this blog, I hope it was of help.

Please drop a comment, if you found it useful.

No comments:

Post a Comment