Global.asa
In an ASP application,the Global.asa file is an optional file that can contain declarations of
objects, variables, and methods that can be accessed by every page.
Note:Each application can only have one Global.asa file and the Global.asa file must be stored in the root directory of the
ASP application.
The Global.asa file can contain only the following:
- Session events
- Application events
- <object> declarations
- TypeLibrary declarations
- the #include directive
Application and Session Events
when the application/session starts or application/session ends ,it is necessary to
tell the application and session objects in Glogal.asa about the work to be done.
The code for this is placed in event handlers. Note: To insert scripts in the Global.asa file, we have to put the
subroutines inside the HTML <script> tag,we do not use
<% and %>:
<script language="vbscript" runat="server">
sub Application_OnStart
' some code
end sub
sub Application_OnEnd
' some code
end sub
sub Session_OnStart
' some code
end sub
sub Session_OnEnd
' some code
end sub
</script>
<object> Declarations
By using the <object> tag,it is also possible to create objects with session or application scope in
Global.asa. Note: The <object> tag
should be outside the <script> tag!
Syntax:
<object runat="server" scope="scope" id="id"
{progid="progID"|classid="classID"}>
.......
</object>
TypeLibrary Declarations
The contents of a DLL file corresponding to a COM object is stored in a TypeLibrary.
The constants of the COM object can be accessed by including a call to the TypeLibrary in the Global.asa file,
and errors can be better reported by the ASP code.
You can declare the type libraries in Global.asa if your Web application relies on COM objects that have
declared data types in type libraries.
Syntax:
<!--METADATA TYPE="TypeLib"
file="filename"
uuid="typelibraryuuid"
version="versionnumber"
lcid="localeid"
-->
|