GLOBAL.ASA | |
The The The
|
GLOBAL.ASA: Comments/Troubleshooting | |
When you make changes to the
Note that any sessions that remain current during this time are
unaffected by your changes to An important consideration for developing your own
You can have procedures and functions in your
Finally, like all other scripts in your web application, you must be
careful to secure your |
Application Object Events and Application Scope | |
<SCRIPT LANGUAGE=strLangEngine RUNAT = SERVER> Sub Application_OnStart Event procedure code... End Sub Sub Application_OnEnd Event procedure code... End Sub </SCRIPT> | |
<SCRIPT LANGUAGE=strLangEngine RUNAT = SERVER> Sub Application_OnStart Event procedure code... End Sub Sub Application_OnEnd Event procedure code... End Sub </SCRIPT>
In the To review the information covered in the Application Object chapter, an ASP application is made up of all the files in a virtual directory and all the files in subfolders under that virtual directory. When a variable or object has application scope, it holds the same value(s) for every current user of the application, and any user can change the value(s) of an application-scoped variable or object. Such a change affects the value as viewed by any user thereafter. |
|
Parameters | |
|
|
Example | |
[Excerpt from GLOBAL.ASA] <OBJECT RUNAT=Server SCOPE=Application ID=AppInfo1 PROGID="MSWC.MyInfo"> </OBJECT> <SCRIPT LANGUAGE = "VBScript" RUNAT="Server"> Sub Application_OnStart Dim objCounters Dim gdatAppStartDate ' The following object variable will hold a Counters ' component. Set objCounters = Server.CreateObject("MSWC.Counters") ' The following application-level variable will ' hold the start date of the application. gdatAppStartDate = Date( ) End Sub Sub Application_OnEnd ' The following code destroys the application-scoped ' Counters component. Set objCounters = Nothing ' The following clears the application-level variable. gdatAppStartDate = " ' NOTE: This code is not strictly necessary in this ' instance as this object and variable will be released ' from memory by the web server itself when the application ' ends. This example simply demonstrates how these event ' procedures work. For suggestions for the Application ' object's use, see the following and Chapter 4. End Sub </SCRIPT> |
|
Notes | |
There are several points to remember about the
Next, if you do have a For further notes on the event procedures of the Application object,
see Chapter 4. |
|
Session Object Events and Session Scope | |
<SCRIPT LANGUAGE=strLangEngine RUNAT = SERVER> Sub Session_OnStart Event procedure code... End Sub Sub Session_OnEnd Event procedure code... End Sub </SCRIPT> | |
<SCRIPT LANGUAGE=strLangEngine RUNAT = SERVER> Sub Session_OnStart Event procedure code... End Sub Sub Session_OnEnd Event procedure code... End Sub </SCRIPT>
In the |
|
Parameters | |
|
|
Example | |
[Excerpt from GLOBAL.ASA] <OBJECT RUNAT=Server SCOPE=Session ID=Tool1 PROGID="MSWC.Tools"> </OBJECT> <SCRIPT LANGUAGE = "VBScript" RUNAT="Server"> Sub Session_OnStart Dim strLogonUser Dim StrUserSecurity ' The following session-level variables will hold ' the user's logon name and security clearance. strLogonUser = Request.ServerVariables("USER_LOGON") strUserSecurity = "PUBLIC" End Sub Sub Session_OnEnd ' The following code destroys the session-scoped ' Tools component. Set Tool1 = Nothing ' The following clears the session-level variables. strLogonUser = " strUserSecurity = " ' NOTE: This code is not strictly necessary in this ' instance as this object and variable will be released ' from memory by the web server itself when the session ' ends. This example simply demonstrates how these event ' procedures work. For suggestions for the Application ' object's use, see later in this chapter and Chapter 10. End Sub </SCRIPT> |
|
Notes | |
For notes on the Session event procedures, see Chapter 10. |
|
Type Library Declarations | |||||||||||
<!-- METADATA TYPE="TypeLibrary" FILE="FileName" UUID="TypeLibraryUUID" VERSION="MajorVersionNumber.MinorVersionNumber" LCID="LocaleID" --> | |||||||||||
<!-- METADATA TYPE="TypeLibrary" FILE="FileName" UUID="TypeLibraryUUID" VERSION="MajorVersionNumber.MinorVersionNumber" LCID="LocaleID" --> Type libraries are accessory files that contain information about the properties and methods of COM objects. These files describe any constants used by the object and the data types of acceptable property values. A type library enables your application to more accurately report errors in your use of the object to which the type library corresponds. It also allows you to use constants defined in the object's DLL. This can significantly lower the complexity of an object's code and increase the readability and reuse of your code without forcing you to create and use Server-Side Includes that can be difficult to maintain for all of your objects. As you know, you can instantiate
application-scoped and session-scoped objects in the
|
|||||||||||
Parameters | |||||||||||
|
|||||||||||
Example | |||||||||||
[Excerpt from GLOBAL.ASA] <!-- METADATA TYPE="TypeLibrary" FILE="Report.LIB" VERSION="1.5" LCID="1306" --> |
|||||||||||
Notes | |||||||||||
This code declares the use of Version 1.5 of the Report COM object's type library. The LCID used is that for French. If Version 1.5 of this COM object's type library is not found or the LCID 1306 (for French) is not supported by the type library, the code will result in an error. When you use a type library from within an ASP application, you are actually using a wrapper-encapsulated version of the type library. IIS creates this wrapper for your type library in the background. For coding style, Microsoft suggests that you include your type
library declarations near the top of the
One problem with using type libraries from multiple COM objects in one ASP application (especially if the COM objects were written by different developers) is the redundancy of constants within the object. You can avoid this redundancy by referring to any constant using the name of the COM object itself as a prefix for the constant name. For example, the adStoredProcedure constant of the ADODB type library can be referred to as ADODB.adStoredProcedure. Finally, the web server can return one of the errors listed in the following table if you incorrectly declare your type library:
|
|||||||||||