Lesson 2: Namespaces in a Web Application
The purpose of this lesson is to introduce key namespaces used to build ASP.NET applications. All of these namespaces are items under the System.Web namespace.
- "The class definitions for objects used in Web Applications reside in the System.Web namespace."
The namespaces: System.Web, System.Web.SessionState, System.Web.Services, System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls, System.Web.Caching, System.Web.Mail, System.Web.Security.
When building a Web application, you will certainly derive from the System.Web.HttpApplication class (to obtain the Web Application object) and the System.Web.UI.Page class (to obtain the Web Form objects).
- "When ASP.NET starts your application, it automatically instantiates the Global object defined in Global.asax...The HttpApplication base class provides the properties and methods to access the subordinate objects for the Global object."
Selected Web Application members: Application, Context, Modules, Request, Response, Server, Session, User.
- "The Page object controls your application's user interface."
Selected Page members: Application, Cache, Controls, Request, Response, Server, Session, Trace.
- "The Request object contains the information sent by the client browser when a page is requested from the application."
Selected Request members: Browser, ClientCertificates, Cookies, Files, InputStream.
- "Use the Response object to form the response sent from the server to the client browser."
Selected Response members: Cache, Cookies, Output.
It may help to mention the System.Web.HttpContext class here because, like the Page object, it exposes the Request and Response objects. This allows "business logic" behind ASP.NET Web pages to handle Response and Request objects without referencing the System.Web.UI namespace of the Page object.