
292
|
Chapter 14: The HttpContext Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
the Page object, so they might not seem important. However, if you are creating
other types of ASP.NET code, such as HttpModules and HttpHandlers, the
HttpContext class can be a lifesaver. Even developers creating only standard
ASP.NET pages might need to use the HttpContext object if they are creating
event handlers in the global.asax file. In some contexts, the traditional objects
used within ASP.NET pages are not available within these global.asax event
handlers.
Table 14-1 lists the properties, collections, and methods exposed by the
HttpContext class.
Comments/Troubleshooting
Many HttpContext class properties are topics in their own right. For instance, the
Application, Response, Request, and Session properties are accessible here, but
covered in detail elsewhere in this book. A couple of methods within HttpCon-
text, however, might require further explanation.
GetConfig sounds like it might be a way to get the
appSettings configuration
information mentioned in the previous chapter. While it is possible to use
GetConfig(“appSettings”) for that purpose, it requires some casting. GetConfig
returns an instance of System.Configuration.ReadOnlyNameValueCollection,
which is a private class. To actually use the returned value, you need to cast it to