
392
|
Chapter 18: The HttpServerUtility Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Notes
The Execute method is a useful feature that first appeared in the IIS 5.0 version of
Active Server Pages. ASP.NET includes an overloaded version of the method,
adding the
Writer argument for capturing, manipulating, and/or saving the output
of the request being executed.
When called passing only the URL, the Execute method automatically inserts the
output of the request into the HTML output stream of the calling page.
When called passing both the URL and an object reference derived from the
Text-
Writer
class (such as StringWriter, StreamWriter, or HtmlTextWriter), the output
is not automatically added to the HTML output stream, but may be obtained, as
in the previous example, by calling the ToString method of the writer class.
GetLastError
LastException = Server.GetLastError( )
Returns the last exception thrown.
Parameter
LastException
An object of type Exception to receive the application’s last exception.
Example
The code in GetLastError.aspx displays a button that, when clicked, calls a server-
side event handler that declares three Integers and purposely divides by zero (a
no-no) to cause an exception. The code in the Page_Error event handler declares
an Exception object and a String, gets the Exception using GetLastError, tests
whether