Chapter 22. The System.Web Namespace
The System.Web
namespace contains some of the
fundamental ingredients for ASP.NET applications. These ingredients include the
classes used for the original built-in ASP objects
(Request
, Response
, Application
, and Server
), as well
as classes for managing cookies, configuring page caching, implementing
tracing, and retrieving information about the web server and client
browser. Aside from the classes required for web services and the Web
Forms user interface, the System.Web
namespace
contains the heart of ASP.NET’s functionality.
Figure 22-1 and Figure 22-2 show
the types in this namespace.
One confusing aspect about the System.Web
namespace
is Microsoft’s “all roads lead to Rome” approach to backward
compatibility. For example, the HttpRequest
class can be accessed on a
Web Form through the Page
class
(Page.Request
), the HttpContext
class
(Page.Context.Request
), and the HttpApplication
class
(Page.Context.ApplicationInstance.Request
). In all cases,
the reference is pointing to the same object. Essentially, the HttpContext
class encapsulates the
fundamental types that relate to an HTTP request. The HttpContext
object is made available to
all IHttpModule
and IHttpHandler
instances (which includes HttpApplication
, System.Web.UI.Page
, and System.Web.UI.UserControl
), and some of its
properties are “magically” copied into these classes for convenience
and backward compatibility. When you use the built-in Request
object on a Web Forms page, for example, ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.