Chapter 6. Debugging Your Web Form Pages

This chapter tackles the three related topics of building, debugging, and tracing your Web projects. The first section examines in detail what happens when you build a project. We’ll also discuss the different types of errors that can occur in an application.

Next, we look at the integrated Visual Studio .NET debugger. You’ll learn how to use the debugger to set breakpoints and step through your code.

Finally, you learn how to take advantage of both page and application tracing. You can use both types of tracing to view debugging information from a live application.

In this chapter, you will learn

  • How to build your application in both debug and release modes

  • The different categories of errors in your application

  • How to use the Visual Studio .NET debugger

  • How to trace the execution of a single page or all pages in an application

Building Your Project

Visual Studio .NET supports three methods for compiling and executing your Web Forms application:

  • Build and Browse

  • Start

  • Start without Debugging

First, you can perform a Build and Browse. This option is available from the File menu and is also available when you right-click a page in Solution Explorer. Finally, you can perform a Build and Browse by using the keyboard combination Ctrl+F8.

When you select a page and perform a Build and Browse, all the pages in the same project as the selected page are compiled. Pages in other (independent) projects are not compiled. After the project is compiled, the selected page appears in a browser window that opens in Visual Studio .NET.

Note

I’m oversimplifying a bit in this section because building one project might cause other dependent projects to be built (even when using the Build command rather than the Build Solution command). For example, building an ASP.NET Web Application project that depends on a Web Control Library project will cause both projects to be built. You can view project dependencies by selecting Project Dependencies from the Project menu.

A second method of compiling pages is by using the Start menu option. You can start an application from the Debug menu by clicking the Start icon on the toolbar (the VCR run button) or by using the F5 keyboard shortcut.

Before you can use the Start option, you need to specify a start page and, if you have multiple projects in your solution, a startup project. You specify a start page by right-clicking a file in the Solution Explorer window and selecting Set As Start Page. You specify a startup project by right-clicking a project in Solution Explorer and selecting Set As Startup Project.

When you start an application, the application builds the project in a solution and opens an external browser that displays the startup page. You must close this external window before you can return to editing the files in the solution.

Tip

If you don’t need to use the debugger, performing a Build and Browse is the fastest way to compile and view a page.

Finally, you can compile an application by using the Start without Debugging menu option. This menu option is available under the Debug menu. You can also start an application without debugging by using the keyboard combination Ctrl+F5. The Start without Debugging command also opens an external browser, so it can be slower than doing a Build and Browse.

Building in Debug and Release Mode

Regardless of the method you use to build an application, the application is compiled in debug mode by default. This is bad. Building an application in debug mode can have a severe impact on performance.

Before you release an application into production, you’ll need to modify two configuration settings. First, select Release from the Solution Configurations drop-down list (see Figure 6.1). After you select Release, make sure that you build your application one more time.

Building an application in release mode.

Figure 6.1. Building an application in release mode.

Second, you’ll need to modify your application’s Web.Config file. Open the Web.Config file from Solution Explorer. Find the <compilation> section and assign the value false to the debug attribute.

When developing an application, you normally need to develop the application in debug mode. If you don’t develop the application in debug mode, you cannot view runtime errors and you cannot use the integrated Visual Studio .NET debugger.

When you build an application in debug mode, the /debug and /optimize compiler options are sent to the C# or VB.NET compiler. The /debug option causes the compiler to generate a programmer database (.pdb) file. Without a .pdb file, Visual Studio .NET cannot display runtime errors. The .pdb file contains a mapping between MSIL code and source code.

The /optimize compiler option tells the compiler to perform automatic optimizations on your code. However, because the compiler may optimize your code by rearranging it, enabling optimization can prevent debugging from working.

Explicit and Dynamic Compilation

A Web Form Page consists of two files—the presentation page and the code-behind file. The two parts of a Web Form Page are compiled in different ways.

The code-behind file must be explicitly compiled. When you compile a project in Visual Studio .NET, you are compiling the code-behind files in the project. All the code-behind files are compiled into a single assembly (.dll file) that has the same name as your project. This assembly is placed in the /bin folder of your application.

Note

If Visual Studio .NET cannot write to the /bin directory, it won’t be able to compile your project. You might run into this issue if, for example, you have Microsoft Index Server running on your development computer. Microsoft Index Server can lock a directory while indexing. To get around this problem, disable Index Server.

You can view this assembly in a project by selecting Show All Files from the Project menu and expanding the Bin folder in the Solution Explorer window. When a project is compiled in Debug mode, this folder will contain a .dll file and a .pdb file. When a project is compiled in release mode, it will contain only the .dll file.

The presentation part of your Web Form Pages—the .aspx files—also must be compiled. However, you are not responsible for compiling the presentation pages. The ASP.NET Framework handles the compilation of these pages for you in a process known as dynamic compilation.

The ASP.NET Framework automatically compiles any .aspx page when the page is first requested. The compiled assembly that corresponds to the requested page is stored in the following folder:

WINNTMicrosoft.NETFrameworkFramework Version Temporary ASP .NET FilesProject Name

If you look in this folder, you’ll find folders and files with strange names like 1e994b and 892323.dll. The .dll files correspond to the compiled presentation pages. If you are really curious, you can open these files with ILDasm, the Intermediate Language Dissassembler, and view their contents.

When the presentation pages in an application are compiled in debug mode (in other words, <compilation debug=true /> in the Web.Config file), a bunch of additional files are added to the folder. For example, you should see files with the extensions .cmdline, .cs, and .vb. The .cmdline files contain the actual statement that was sent to the compiler to dynamically compile a presentation page. The .cs and .vb files contain the source code for the presentation page class file.

Displaying Errors in Your Application

There are four types of errors that might prevent a Web Form Page from executing:

  • Configuration Errors—These are caused by errors in the Web.Config file (for example, if you have an opening tag without a matching closing tag).

  • Parser Errors—These are caused by problems in a Web Form Page (for example, if you attempt to use the non-existent <asp:DoesNotExist> control).

  • Compilation Errors—These errors are language specific and can be caught at compile time (for example, assigning a value of the wrong data type to a property).

  • Runtime Errors—There are errors that could not be caught by the compiler. Examples include null reference and division by zero exceptions. These are the nastiest errors because they are the most difficult to debug.

There are two configuration settings that determine how errors are displayed. First, you need to enable debugging for both the code-behind files and the presentation pages in your application to view detailed runtime error information. Unless debugging is enabled, .pdb files are not generated and the source of the error cannot be displayed (both of these options are enabled by default).

Second, by default, errors are not displayed on a remote computer for security reasons. If you are developing an application on a remote Web server, you’ll need to disable custom errors to see error messages. Open the Web.Config file from the Solution Explorer window, find the <customErrors> tag and assign the value Off to the mode attribute. Disabling custom errors will cause errors to be displayed on a remote computer. For this reason, you need to be careful to re-enable custom errors when you are ready to deploy your Web application.

After you have made these configuration changes, you can view error information in two places. When you compile the code-behind pages in a project, you can view any compilation errors by opening the Task List window (Select Show Tasks from the View menu and open Build Errors). All other errors will appear in the Web Form Page itself when it is displayed in a browser.

Note

The Task List window also displays Intellisense code validation errors. For example, if you attempt to nest a <ul> tag directly beneath a <table> tag in a presentation page, an error will appear in the Task List window with a red squiggly line. These errors do not prevent your project from being compiled.

Using the Visual Studio .NET Debugger

You can use the integrated Visual Studio .NET debugger to step through an executing ASP.NET application line-by-line and view the values of any variables. The debugger is an invaluable tool for tracking down problems in your code.

In the following sections, you’ll learn how to set breakpoints, create watches, handle exceptions, and debug client-side scripts and SQL stored procedures.

Adding Breakpoints

Before you can debug an application, you need to set one or more breakpoints. A breakpoint is a point in your code where you want the execution of your application to temporarily stop. After you stop your application at a breakpoint, you can step through your code and view the values of variables.

You set a breakpoint by clicking on the left margin of the Code Editor. A breakpoint is represented with a filled red circle (see Figure 6.2).

Adding a breakpoint.

Figure 6.2. Adding a breakpoint.

After you add a breakpoint, start your application by selecting Start from the Debug menu (you’ll need to specify the Startup Page and Startup Project in the Solution Explorer window). The Web Form Page that was selected as the start page will stop executing when the breakpoint is hit.

Tip

As an alternative to setting a breakpoint, you can use the Run to Cursor command. Right-click anywhere within the Code Editor and select Run to Cursor.

Stepping Through Code

After your code has hit a breakpoint, you can step through your code line-by-line by using the commands from the Debug toolbar. From the Debug toolbar, the Debug menu, or by using special keys, you can:

  • Continue—Resumes execution of the application until the next breakpoint is hit or the application terminates (use F5 from the keyboard).

  • Break All—Enables you to manually break the execution of an application. Clicking Break All when an application is running will cause the application to stop in the same way as if a breakpoint were hit (use Ctrl+Alt+Break from the keyboard).

  • Stop Debugging—Disables continued debugging for the application. Causes all future breakpoints to be ignored (use Shift+F5 from the keyboard).

  • Restart—Restarts the application and stops at the first breakpoint (use Ctrl+Shift+F5 from the keyboard).

  • Show Next Statement—Displays the next statement that will be executed (not available from the Debug menu).

  • Step Into—Executes the next line of code stepping into methods, functions, and subroutines (use F11 from the keyboard).

  • Step Over—Executes the next line of code stepping over methods, functions, and subroutines (use F10 from the keyboard).

  • Step Out—Executes the next line of code that is outside the current method, function, or subroutine (use Shift+F11 from the keyboard).

The Step Into and Step Over commands require additional explanation. The only difference between Step Over and Step Out is when the next statement to be executed is a method, function, or subroutine. If you use Step Into, the debugger steps into the function, executes the first statement in the function, and then stops execution. If you use Step Over, the debugger executes the entire function and stops execution at the next line.

Note

If you have used earlier versions of Visual Studio, you might have different keyboard shortcuts ingrained into your fingertips for stepping through code. You can change any keyboard shortcut by selecting Options from the Tools menu and selecting the Environment, Keyboard folder. In this case, you’ll want to change the shortcuts for the Debug.StepInto and Debug.StepOut commands.

Alternatively, you can change keyboard shortcuts by changing your profile. Select Show Start Page from the Help menu and click My Profile.

You can also control execution by dragging the yellow arrow that appears at the margin of the Code Editor. For example, if you drag the yellow arrow down, the intervening code will be skipped.

Debugger Windows

There are a number of windows that appear when you are using the debugger. You can use these windows to monitor the current state of your application when your application is running. Not all of these windows appear automatically, but you can open any of them by selecting Windows from the Debug menu.

  • Breakpoints—Displays information about all the current breakpoints.

  • Running Documents—Displays all the open documents. This window is useful when you are performing client-side script debugging.

  • Watch—Displays Watch windows for viewing the current state of selected variables.

  • Autos—Displays the values of selected variables automatically. When used with C#, this automatically displays the values of variables located in the current statement and previous statement. When used with VB.NET, it displays the values of variables in current statement, the previous three statements, and next three statements.

  • Locals—Displays the values of all variables in the current context. For example, it displays the values of all variables contained in the current method, function, or subroutine.

  • This/Me—Displays all the properties of the current object, (for example, the window displays all the properties of the current Web Form Page).

  • Immediate—Enables you to view and modify the values of variables directly. You can print the values of variables and assign new values to variables from this window.

Note

This is not a complete list of all the windows available while debugging. Some of the windows are pretty specialized. For example, you can view the assembly code that corresponds to the currently executing code by opening the Disassembly window.

Adding Watches

A watch enables you to see the current state of a variable. The Visual Studio .NET debugger supports two types of watches—Watches and QuickWatches.

Tip

You can also view the current value of any variable by hovering your mouse over the variable in the Code Editor. Its current value will appear in a Tooltip.

You can open up to four Watch windows from the Debug, Windows menu. After you open a Watch window, you can add as many variables to the window as you want. There are several ways that you can add an individual variable to the Watch window:

  • Select the variable in the Code Editor and drag it onto the Watch window.

  • Select the variable in the Code Editor, right-click, and select Add Watch.

  • Type the name of the variable in the Watch window.

As you step through your code, the values of variables in the Watch windows are automatically updated (see Figure 6.3). You can even modify the values of variables directly in the Watch window. Modifying the values of variables modifies their values in the executing code.

Adding a watch.

Figure 6.3. Adding a watch.

The second type of watch is a QuickWatch. You can open a QuickWatch window by selecting QuickWatch from the Debug menu or by right-clicking in the Code Editor and selecting QuickWatch. If you select a variable in the Code Editor before opening the QuickWatch window, the variable and its current value will automatically appear in the QuickWatch window.

You can use the QuickWatch window for more than just viewing the values of variables. You can also use the window to evaluate expressions and get the return values of methods and functions. After you enter an expression, click Recalculate to see the expression’s value (see Figure 6.4).

Using a QuickWatch.

Figure 6.4. Using a QuickWatch.

Debugging and Exceptions

All errors in the .NET Framework are represented by exceptions (instances of the Exception class or a derived class). For example, a division by zero error is represented by the DivideByZeroException class.

You can configure the debugger so that when an exception is thrown in your application, the application will automatically switch back to the debugger in the same way as if it hit a breakpoint. That way, you can examine the values of all the variables at the point when the exception was hit. You can even decide to continue the execution of the application after the exception.

You configure how the debugger handles exceptions by selecting Exceptions from the Debug menu. The Exception dialog box enables you to specify responses to two different conditions. First, you can indicate that your code should break into the debugger as soon as there is an exception. You also can indicate that your code should switch to the debugger when an exception is not handled by your code.

These options enable you to handle two different scenarios. You might want to debug an exception even when it is being handled by your code in a Try...Catch block. Alternatively, you might want to break to the debugger only in the case of unhandled exceptions.

Unfortunately, these options can be confusing in the case of Web Form Pages. All exceptions in a Web Form Page are automatically handled by the ASP.NET Framework. Therefore, the only meaningful option when debugging a Web Form Page is to select the option to break into the debugger when the exception is thrown.

You can select this option by selecting Common Language Runtime Exceptions and selecting Break Into the Debugger in the When the Exception Is Thrown panel. After you select this option, a red ball with an X should appear next to Common Language Runtime Exceptions (see Figure 6.5).

Handling exceptions in the debugger.

Figure 6.5. Handling exceptions in the debugger.

Debugging Client-Side Script

You can use the debugger to debug client-side script in your Web Form Pages. The debugger can be used with both VBScript and JavaScript client-side code.

The first step in enabling client-side script debugging is to enable debugging in Internet Explorer:

  1. In Internet Explorer, Select Internet Options from the Tools menu.

  2. Click the Advanced tab.

  3. Make sure that Disable Script Debugging is unchecked (this option is located under the Browsing category).

Unfortunately, you can’t set breakpoints in the same way for client-side script as you can for normal server-side code. Instead of setting a breakpoint in the Code Editor, you need to use either the debugger statement (in the case of JavaScript) or the Stop statement (in the case of VBScript).

For example, the following client-side JavaScript script will break into the debugger when the debugger statement is hit:

function window_onload() {
  var someVar = 23;
  debugger;
  document.write( someVar );
}

When debugging VBScript scripts, you need to use the Stop statement:

Sub window_onload
  Dim someVar

  someVar = 23
  Stop
  Document.write(someVar)
End Sub

When the debugger or Stop statement is reached, the Web Form Page will break into the debugger. At that point, you can step through the client-side code and create new breakpoints in the normal way.

Debugging SQL

You can use the debugger to debug SQL stored procedures, functions, and triggers. You can debug these objects directly or in the context of executing an application.

For example, if you want to step through a stored procedure statement-by-statement, you can simply right-click the stored procedure in the Server Explorer window and select Step Into Stored Procedure. You can also step through a stored procedure when the stored procedure is open in the Code Editor by right-clicking the Code Editor and selecting Step Into Stored Procedure (see Figure 6.6).

Debugging a stored procedure.

Figure 6.6. Debugging a stored procedure.

The more interesting case is when you want to debug a stored procedure in the context of an executing ASP.NET Web application. Before you can do this, you must enable SQL debugging for the application:

  1. Right-click the name of your project in the Solution Explorer window and select Properties.

  2. In the Properties dialog box, select the Configuration Properties folder and select the Debugging node.

  3. Check the SQL Server Debugging check box.

After you complete these steps, you can place a breakpoint in a stored procedure and stop an executing ASP.NET application at that breakpoint. The debugger can move seamlessly between your ASP.NET code and the SQL statements in the stored procedure.

Note

I’m assuming in this section that you are debugging an SQL stored procedure located on the same server as Visual Studio .NET and your Web server. There are additional configuration steps that you must complete to debug stored procedures located on a remote SQL Server. See the following section in the Visual Studio .NET documentation:

Visual Studio .NET, Developing with Visual Studio .NET, Building, Debugging and Testing, Debugging, Debugging SQL

Page and Application Tracing

Tracing enables you to output the values of variables, or other debugging information, while your application is running. You can use tracing as an alternative to using the debugger to find bugs while developing an application.

One advantage of tracing over the debugger is that you can use tracing with a “live” Web site. For example, suppose that something has gone horribly wrong with your Products.aspx page. Your start getting customer service reports of errors in this page, but you don’t know the source of the errors.

You wouldn’t want to use the debugger to track down an error on a live Web site because placing an application in debug mode carries with it a severe performance penalty. In this situation, it makes more sense to use tracing. You can use tracing to find out what is happening behind the scenes in the Products.aspx page without the rest of the world knowing that you are debugging the page.

The ASP.NET Framework supports two types of tracing—page and application tracing. We’ll examine both types of tracing in the following sections.

Using Page Tracing

In the old days, you would track down errors in an ASP page by using the Response.Write() statement. If you weren’t sure about the current value of a variable at a certain point in your code, you would Response.Write() the value of the variable to the browser window.

The Response.Write() statement, used as a debugging tool, has some serious drawbacks. First, if you forget to remove a Response.Write() statement before you move your application into production, the whole world will see your debugging information. Second, you can’t use Response.Write() on a “live” Web application because, once again, everyone in the world will see your debugging information.

Instead of using Response.Write(), you can use the Trace.Warn() statement. Unlike the Response.Write() statement, you can hide the output of every Trace.Warn() statement in a page with a single switch. Furthermore, unlike the Response.Write() statement, the output of the Trace.Warn() statement only shows up on the local machine by default. That way, the rest of the world does not see your debugging information.

Perform the following steps to enable page-level tracing:

  1. Create a new Web Form Page named TestTrace.aspx.

  2. In the Properties window, select DOCUMENT and assign the value FlowLayout to the pageLayout property and the value True to the trace property.

  3. Add TextBox, Calendar, and DataGrid controls to the page by dragging these controls from the Toolbox onto the Designer surface.

  4. Double-click the Designer surface to switch to the Code Editor and enter the following code for the Page_Load handler:

    C#

    private void Page_Load(object sender, System.EventArgs e)
    {
      Trace.Warn( "A message from me!" );
    }
    

    VB.NET

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
    VB.NET MyBase.Load
      Trace.Warn("A message from me!")
    End Sub
    
  5. Right-click the TestTrace.aspx page in the Solution Explorer window and select Build and Browse.

When the TestTrace.aspx page opens, you should see the page in Figure 6.7. Notice that additional information has been automatically appended to the bottom of the page.

Using page tracing.

Figure 6.7. Using page tracing.

Warning

Page-level tracing does not work well with pages in Grid Layout mode. The problem with Grid Layout mode is that it absolutely positions elements on a page so the tracing information tends to get hidden behind the page content.

The two most useful sections appended to the page are the Trace Information and Control Tree sections. The Trace Information section displays information about the Page Init, PreRender, SaveViewState, and Render events. It also displays any custom trace information that you outputted with the Trace.Warn() statement, so your custom message “A message from me!” appears in this section.

The Trace Information section displays execution speed statistics for each entry. It displays the time in seconds between the execution of the first entry and the current entry. It also displays the time in seconds between the previous entry and the current entry. You can use these statistics to identify slow code.

The Control Tree section shows all the controls contained in the current page. If you look in the control tree, you should see the TextBox, DataGrid, and Calendar controls that you added to the page. The Control Tree section displays the Render and View State size for each control.

Tip

The View State information is valuable when you want to determine which controls in a page are consuming the most View State. For example, if you are using a DataGrid control only to display information, you should disable View State for this control by assigning the value False to the control’s EnableViewState property (to learn more about View State see Chapter 17, “Maintaining Application State”).

By default, the trace information appears only when the page is opened on the same server as the Web server. This is both good and bad. It means that the rest of the world will not see your trace information when you are debugging a live Web application. However, it also means that you won’t see the trace information when developing an application on a remote machine.

You can configure your application to show trace information remotely by modifying the Web.Config file:

  1. Open the root Web.Config file from the Solution Explorer window.

  2. Find the <trace> section.

  3. Assign the value false to the localOnly attribute (be careful, this file is case sensitive!).

  4. Save the Web.Config file.

Note

You can use the Trace.Write() statement instead of the Trace.Warn() statement. The two statements behave identically except for the fact that the Trace.Warn() statement outputs messages in red and the Trace.Write() statement outputs messages in black. I typically use the Trace.Warn() statement because it is easier to see the output.

Placing Trace Messages in Different Categories

If you need to output a significant number of trace messages from a page, you might want to group the trace messages into categories. You can assign a trace message to a category by passing an additional parameter to the Trace.Warn() method:

C#

Trace.Warn("Trace Category 1", "A message from me!" );

VB.NET

Trace.Warn("Trace Category 1", "A message from me!" )

The category can be any string. It shows up in the left column of the Trace Information section when tracing is enabled.

By default, the messages in the Trace Information section appear in order of execution. If you are using categories, it is more useful to group related trace messages by their category. You can do this by modifying the traceMode property of the DOCUMENT in the Properties window. This property accepts the two values SortByTime (the default) and SortByCategory.

Tracing and Exceptions

Trace information appears even when there is a runtime error in the page. This means that you can use tracing to output the values of variables in statements leading up to the exception. The exception information is automatically appended to the Trace Information section.

You can also explicitly write out an exception. This is useful when you are handling exceptions in your code with Try...Catch blocks. For example, the following code will output the division by zero exception to the Trace Information section even though it was handled:

C#

int zero = 0;
int results;

try
{
  results = 12 / zero;
}
catch (Exception ex)
{
  Trace.Warn("Exceptions", "An Error!", ex);
}

VB.NET

Dim zero As Integer = 0
Dim results As Integer

Try
  results = 12 / zero
Catch ex As Exception
  Trace.Warn("Exceptions", "An Error!", ex)
End Try

In this code, three parameters are passed to the Trace.Warn() statement. The first parameter represents the trace category, the second parameter represents a custom message, and the final parameter represents the exception. Because the exception was handled, the exception information will only appear in the Trace Information and not on the page.

Programmatically Enabling Tracing

In a production application, you don’t want page tracing information to be displayed. However, if something has gone wrong with a page, you might want an easy way to display the trace information. For example, when a certain secret string is passed in the query string, you want the trace information to be displayed.

You can programmatically enable or disable page tracing with the Trace.IsEnabled property. You can use the following Page_Load method to enable tracing only when the query string trace=secret is passed to the page:

C#

private void Page_Load(object sender, System.EventArgs e)
{
  if (Request.QueryString[ "trace" ] == "secret")
    Trace.IsEnabled = true;
}

VB.NET

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
VB.NET MyBase.Load
  If Request.QueryString("trace") = "secret" Then
    Trace.IsEnabled = True
  End If
End Sub

For security reasons, you’ll want to be careful to use a closely guarded password instead of secret. Remember that it is possible to steal database passwords and other sensitive data when tracing is enabled.

Using Application Tracing

Application tracing enables you to gather trace information for every page running in an application. When you enable application tracing, you can view trace information in a special page named Trace.axd.

If you open the Trace.axd page in your browser, you’ll receive an error. For security reasons, application tracing is disabled by default. Before you can use application tracing, you need to modify the Web.Config file:

  1. Open the Web.Config file from the Solution Explorer window.

  2. Find the <trace> section.

  3. Assign the value true to the enabled property.

After you complete these steps, open the Trace.axd page in a Web browser. You should see the page in Figure 6.8.

Using application tracing.

Figure 6.8. Using application tracing.

The Trace.axd page shows tracing information for 10 requests. After 10 requests, you must flush the current trace information by clicking the Clear Current Trace link at the top-right of the page.

Note

You can control how many pages are tracked in the Trace.axd page by changing the requestLimit attribute in the <trace> section of the Web.Config file.

If you open another page in the Web browser—for example, the TestTrace.aspx page that we created in the previous section—and return to the Trace.axd page, you’ll see a new entry that corresponds to the page that you requested. If you click View Details, you’ll see all the trace information generated for that page.

It’s important to note that the trace information will contain any custom trace messages that were created with the Trace.Warn() statement. This means that you can disable page tracing for a page but still be able to see your custom trace information for the page by opening the Trace. axd page.

Summary

In this chapter, you learned how to build, debug, and trace your ASP.NET Web applications. In the first section, you looked at the topic of building applications in detail. You learned how to build an application in both debug and release mode. You also learned about the different types of errors that can be raised when building a Web application.

Next, you learned how to use the integrated Visual Studio .NET debugger. You learned how to set breakpoints and add watches. You also learned how to debug client-side script and SQL stored procedures, triggers, and functions.

Finally, you examined the topic of tracing. You learned how to output custom trace information by taking advantage of both page and application tracing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset