If you’re getting this error when trying to debug an ASP.NET Web application on IIS7 or greater, check the system.webServer element in your Web.config. If you have the httpErrors element configured, you won’t be able to debug. For your local dev environment, remove or comment out the httpErrors element, and you should be good to go.
From my ASP.NET 1.1 days, I have a hazy memory of Visual Studio’s debugging startup process requesting a bogus URL on the target Web site, and then doing something with the 404 response prior to launching the debugging session. Obviously, if it’s expecting a 404 or the page to contain certain text, redirecting to an error page will prevent you from launching the debugger successfully.
If you happen to know specifically why this happens, please leave a comment (or contact me if comments are closed), and I will gladly update this entry.