Page and Application Context in Web Forms Applications
When a Web application runs, ASP.NET maintains information about the current application, about each user session, the current HTTP request, the requested Web Forms page, and so on. The ASP.NET page framework contains a series of classes to encapsulate this context information.
ASP.NET makes instances of these classes available as intrinsic objects that you can access from your code. The following table lists these intrinsic objects and the classes they are instances of.
Note Although the classes that define these objects are new with ASP.NET, the objects are used in the same way as with previous versions of ASP.
|Object Name||Description||ASP.NET Class|
|Response||Provides access to the output stream for the current page. You can use this class to inject text into the page, write cookies, and more. For details, see Page.Response Property.||HttpResponse|
|Request||Provides access to the current page request, including the request headers, cookies, client certificate, query string, and so on. You can use this class to read what the browser has sent. For details, see Page.Request Property.||HttpRequest|
|Context||Provides access to the entire current context (including the request object). You can use this class to share information between pages.||HttpContext|
|Server||Exposes utility methods that you can use to transfer control between pages, get information about the most recent error, encode and decode HTML text, and more.||HttpServerUtility|
|Application||Provides access to application-wide methods and events for all sessions. Also provides access to an application-wide cache you can use to store information. For details, see Application State.||HttpApplicationState|
|Session||Provides information to the current user session. Also provides access to a session-wide cache you can use to store information, along with the means to control how the session is managed. For details, see Session State.||HttpSessionState|
|Trace||Provides a way to get both system and custom trace diagnostic messages to display in the HTTP page output. For details, see ASP.NET Trace.||TraceContext|
The following topics show examples of how the intrinsic objects can be used.