From the perspective of ASP, a web application is made up of all of the web pages contained in a virtual directory and its subdirectories. A session is a period of time during which a particular user is accessing pages in the application. A session begins when a user accesses a page in the application and ends when script on a page explicitly terminates the session or after a period of time has elapsed with no new page access. The default period of time is 20 minutes. The application is said to begin when the first session begins and to end when the last session ends.
Application and session startup and shutdown are ideal times to
perform initialization and cleanup activities. For the application to
be notified of these events, a file called
global.asa must be in the application’s
root folder, and in this file must be script to handle these events.
Example 11-3 shows a skeleton
Example 11-3. Skeleton global.asa File
<script language="VBScript" runat="Server"> Sub Application_OnStart ' Application-wide initialization goes here. End Sub Sub Application_OnEnd ' Application-wide cleanup goes here. End Sub Sub Session_OnStart ' Per-session initialization goes here. End Sub Sub Session_OnEnd ' Per-session cleanup goes here. End Sub </script>
Note the use of
<SCRIPT> tag to identify the enclosed text as VBScript that is to be run by the server. VBScript is the default scripting language in IIS unless an administrator changes this ...