17.1 CommentsTroubleshooting

17.1 Comments/Troubleshooting

The Response object provides control over both the format of the output sent to the browser and the content. In fact, an ASP.NET page can be written with no static HTML content whatsoever, and can generate that content exclusively through calls to the properties and methods of the response object, if desired. This provides the ability to programmatically generate not just HTML output dynamically, but any output the browser is capable of displaying, including image content and XML. This generation allows ASP.NET to be incredibly flexible in its response to user actions.

In classic ASP, the Response object's Write method was often used for quick and dirty debugging, such as to display a message indicating that a certain point in a page was reached or to display the value of variables used within the page. This simple and effective debugging technique had one major flaw: frequently, these calls to Response.Write were left in a page that was moved from a development server to a production server, resulting in end users seeing the debugging message hardly a desirable outcome. In ASP.NET, the new Trace object (a property of the Page class) provides the ability to write messages to a central trace log rather than to the page itself (although trace output can optionally be directed to the page). This feature allows developers to use the same simple debugging techniques while significantly reducing the likelihood of end users inadvertently seeing debug messages. Tracing in ASP.NET is discussed in Chapter 10.

In this chapter, we'll use the following code listing as the basis for most examples in the chapter. Unless otherwise noted, each example will consist of only the Page_Load event handler for that particular example. Any output messages or return values displayed will be shown as the Text property of the ASP.NET Label control named Message or displayed by calling Response.Write:

<%@ Page Language="vb" %> <html>    <head>       <script runat="server">          Sub Page_Load( )             'Example code will go here          End Sub       </script>    </head> <body>    <asp:label  runat="server"/> </body> </html>


ASP. NET in a Nutshell
ASP.NET in a Nutshell, Second Edition
ISBN: 0596005202
EAN: 2147483647
Year: 2003
Pages: 873

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net