
307
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Chapter 15HttpException Class
15
The HttpException Class
The HttpException class provides a container for communicating error informa-
tion from various classes used in ASP.NET. The
Page, HttpRequest, HttpResponse,
HttpServerUtility, and other classes all use the HttpException class to communi-
cate information about errors that occur when calling their methods or properties.
The
HttpException class is derived from the Exception class, the base class for
all exceptions in the .NET Framework. HttpException adds two methods,
GetHtmlErrorMessage and GetHttpCode, as well as other constructor over-
loads that create HttpException instances based on HTTP error codes.
In addition to its role in communicating error information from the Request,
Response, and other ASP.NET intrinsic objects, the
HttpException class can be
useful in communicating error information from custom components or controls
that communicate via HTTP. When an HTTP error occurs in such a component,
you can use one of the constructor overloads for the
HttpException class to create
an instance of HttpException that contains the HTTP status code associated with
the result, along with a custom error message, if desired, to the client of the
component. This allows you to provide clients with rich, specific error informa-
tion that ...