The Application_OnStart Function

The Application_OnStart Function

The Application_OnStart function is called before any .asp files are processed — before any text or graphics are rendered and sent to the user's browser. Within this function, the following call to the CreateObject method on the Active Server Pages Server object creates the CDO Rendering Library RenderingApplication object. If this call succeeds, the objRenderApp variable contains a pointer to the new object.

Set objRenderApp = Server.CreateObject("AMHTML.Application")

With the pointer retrieved, it is now possible to work with this CDO Rendering Library object — to call its methods and set its properties. Because a single RenderingApplication object can be shared by all currently active sessions, this is the only time the object needs to be created. The pointer to the RenderingApplication object is stored in the Active Server Pages Application object, using the following call.

Set Application("RenderingApplication") = objRenderApp
 

This call makes this instance of the object globally accessible so that any session can use it. The "RenderingApplication" tag is assigned arbitrarily and used to identify the storage location of the pointer to the CDO Rendering Library object. You can later use this tag to retrieve the pointer because it differentiates the object from anything else stored in the Active Server Pages Application object. Now, during processing of any ASP script in this virtual root, the RenderingApplication object can be retrieved from the Active Server Pages Application object.

Next, the impersonation handle on the Active Server Pages Application object is initialized with the following call. Strictly speaking, this call is unnecessary because this handle is empty before it is set. However, this call is used to remind the developer that the hImp variable needs to be reset later, in the Application_OnEnd function.

Application("hImp") = Empty