ASP.Net Web Forms Applications, Web Application Context...

ASP.Net Web Forms Applications

A set of wcb forms and other files will create a single ASP.Nct Web Forms application to which users send requests and receive HTML responses. In fact, as shown in Fig. 4.1, this application consists of a runtime environment created by Microsoft specialists and software code created by developers to solve an application problem. The developer must be able to customize the runtime.

Web Application Context

When processing requests for a web application, the runtime creates its context, a set of objects that can be used in a web application to interact with it. The description of the main classes, objects of which constitute the context of the web application, is given in Table. 4.5.

Table 4.5

Web application context classes




Objects of this class store the application state and data available to all users of the application


Objects of this class contain all the information about the current 1-PTP request and provide methods for working with it


Objects of this class contain the code of the generated ITML response page and provide methods of working with it


Objects of this class provide auxiliary methods for processing a query


Objects of this class contain user data available in the current session


Interface to an object that contains information about the current user (if it is supported)


Objects of this class contain all the information about the context of query execution


Global objects of this class allow temporary storage of data in the cache; the runtime itself determines when this data can be deleted


Objects of this class contain information specific to the current user (if supported)

The context objects are accessed mainly using properties of the Page class.

Web application events

When processing a request to a web application, the runtime initiates a large set of events:

• events associated with the wcb application and the user's session;

• events related to the web-form as a whole (events of the class Rade, life cycle of the page);

• events related to server-side ECs (events of the corresponding classes, the life cycle of the EC).

For all events, you can write handlers, methods that will be called by the runtime of the web application when this event occurs.

Web application events can also be divided into the following two types:

• events that occur in special cases, such as the beginning and end of the web application (Application_Start and Application_End), and the beginning and end of the user session (Session_Start and Session_End);

• events that occur when processing each HTTP request (such events are more than 20), for example BeginRequest, AuthenticateRequest, EndRequest, etc.

To create event handlers for such events, add the global.asex file (the Website => AddNewltem command) to the web application and include the event handler methods in it. The event handler for special cases is already included in the global.asex file, and event handlers for HTTP requests can be added. The connection between the event and the handler is performed by the name of the handler method. Handler methods must have special names of the following form: Application_OnXxxx (), where Xxxx is the name of the event being processed. For example, the event handler for the end of the HTTP request processing EndRequest has the following form:

protected void Application_OnEndRequest () {

Response.Write ( & lt; hr/& gt; The processing of the HTTP request ended in +



When processing a request t