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.
In Visual Studio 2008, when you add a new Web form to your project, the "using" section of the code-behind contains a lot noise:
You may very well need some of those namespace declarations, but odds are high that you don't need them all. But which ones can you remove without breaking your page?
Visual Studio has a nice feature called Organize Usings, which you access by right-clicking anywhere in the code-behind page. The menu looks like this:
When you click on "Remove and Sort", it removes any unused "using"s and sorts those that remain.
So now, instead of the mess that we had before, we have a much cleaner "using" section in our source code file:
Pretty slick, huh?