Registering ASP.NET with the specified Web Server
Posted on November 12th, 2005
Sometimes the wisdom of crowds really sucks.
Take the relatively common problem of getting ASP.NET properly acquainted with IIS so that you can do your .NET development from Visual Studio and take over the world and so forth. I do a piddling amount of .NET development and I've gotten snagged by this several times. One day everything is fine and then the next, unexplicably, you find yourself staring down this bad boy:

"Unable to run ASP.NET Web applications or services", eh? We'll just see about that. So off you go to Google, fingers itching to type that ridiculously long phrase into the search box just so you can show it who's boss. Or maybe you give that Help button a click. Sooner or later you're bound to come across the canonical solution to this problem, which is to run the aspnet_regiis utility from the closest available DOS window. Like so:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.nnnn\ where nnnn represents a four-digit build number. Look under the highest number. Run the utility using the /i switch: aspnet_regiis /i
Maybe that does the trick and you immediately find yourself back in business. Maybe it doesn't. Maybe you run that aspnet_regiis.exe utility six times over and upside and down, rebooting vigorously along the way for good measure, yet that bastard error message still comes back to taunt you every time. What do you do? What do you do!?
I can tell you what you don't do, and that's spend crazy time combing through Google for any trace mention of an alternate solution. Sure, somebody out there undoubtedly had this exact problem already and figured out how to dodge it, but either they kept the answer to themselves or have crappy++ communication skills and you won't find it anyway. Instead, you'll get page after page telling you things about about aspnet_regiis that you already know. That, or you'll detour into the esoterics of switching between one version of .NET and another. In this case, the crowd has wisdom all right but it's not the kind of wisdom you need.
Here's what I figured out. Let's say you've run aspnet_regiis and can even get your application to load in a browser just fine-- it's just Visual Studio that isn't cooperating. Visual Studio's error message is talking smack about your web server, but maybe the real problem is more subtle. Open a DOS window and ping localhost. Now ping the name of your local machine. If you don't get the same IP, that might be the trouble.

Unless you've messed with the default settings, IIS will happily serve up your site on any valid IP address. That can be 127.0.0.1, or maybe 192.168.x.x. It's not so straightforward with Visual Studio IF your internal network settings are such that your local machine maps to something other than 127.0.0.1. Here's what I saw when I pinged localhost and the local machine:

When I opened the .sln file for the Visual Studio project I was trying to open, I saw that the URL it specified used localhost rather than 192.168.x.x:
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "myproject",
"http://localhost/myproject/myproject.vbproj", ...
When I created the project, this worked fine. But between then and now something changed with my network settings which forced me to switch that URL to the IP address that I got when I pinged my machine's name:
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "myproject",
"http://192.168.x.x/myproject/myproject.vbproj", ...
Once I did that, everything was wine and roses again. The error message was right, in a sense, but the cause had nothing to do with IIS or .NET. This time at least.