There is nothing special about the process of debugging Web applications. You do things such as set breakpoints, step through the code, examine variables, and so on. The tricky part is configuring Visual Studio .NET so that you can actually run the debugger. This requires two steps to be completed.
The first step is to make sure you have in the Web application's root virtual directory a Web.config file with compilation tag that has a debug attribute set to true:
<compilation debug="true" />
The preceding code is case sensitive. You must enter the attribute exactly as shown previously or debug mode will not be set.
With debug mode set, the ASP.NET runtime will generate debugging symbols for a dynamically generated Web page class. It also enables the debugger to attach to the Web application.
Enabling debug mode greatly affects the performance of your ASP.NET application. You should disable debug mode before you deploy your Web application.
The second step is to update your configuration debug properties to support debugging. This requires you to perform the following steps:
Open up the Properties of the Web application.
Select the Debugging folder (see Figure 14-8).
Figure 14-8: The HelloWorld Configuration Properties Debugging folder
Set the Command to aspnet_wp.exe. It might be required that you set the entire path to aspnet_wp.exe if the aspnet_wp.exe executable is not on the executables path.
Set Attach to yes.
Notice that the HTTP URL is already set correctly because you entered it when you executed the Web page earlier.
After you close the configuration dialog box, you press the F5 key to start debugging your Web Form or select Start from the Debug main menu. Figure 14-9 shows HelloWorld stopped at a breakpoint.
Figure 14-9: Debugging HelloWorld
If you get a dialog box that displays the message "Unable to start debugging on the Web server" instead of your Web application, when you start your debugging session, try specifying your machine name instead of "localhost" in the HTTP URL edit box. For example, on my system I would enter http://Amidala/HelloWorld/HelloWorld.aspx.