GLOBAL.ASA

The GLOBAL.ASA file is where you declare objects, variables, and event handlers (for the OnStart and OnEnd event procedures for the Application and Session objects, specifically) that have session or application scope. There can be only one GLOBAL.ASA file per virtual directory or ASP application. For example, suppose you have a Search ASP application made up of all the scripts in the /Search virtual directory. You can have only one GLOBAL.ASA file in the virtual directory, and it must be in the root of the directory (/Search). A second GLOBAL.ASA file anywhere else in any subdirectory of /Search will be ignored by ASP.DLL.

The GLOBAL.ASA file can contain no displayable content; any such content is ignored by ASP.DLL. Any script that is not encased in a <SCRIPT> tag results in an error, as does the instantiation of a server component that does not support session- or application-level scope. Finally, this file must be named GLOBAL.ASA and cannot reside anywhere other than in the root of the virtual directory that makes up the ASP application. Like other scripts, you can use any supported scripting language in the GLOBAL.ASA file, and you can group event procedures that use the same language within a common set of <SCRIPT>...</SCRIPT> tags.

The GLOBAL.ASA file section of this chapter covers the following topics:

  • Application object events and application scope

  • Session object events and session scope

  • Type library declarations

Get ASP in a Nutshell, 2nd Edition 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.