Extending the Scope of the RenderingApplication Object

When you create the RenderingApplication object with the Server.CreateObject method in Application_OnStart, you assign it to a local variable, which limits its lifetime to that of the Application_OnStart function.

Because of this limitation, it is a good idea to store the RenderingApplication object in the Active Server Pages Application object. The Active Server Pages application is global, so storing the RenderingApplication object expands its scope to let it be accessed by other scripts, and extends its lifetime to that of the application. To do this, apply a name to the RenderingApplication object and save it into a table for later reference, using a call like the following:

Set Application("RenderingApplication") = objRenderApp
 

You can release the RenderingApplication object by setting its value in the Active Server Pages Application object to Nothing:

Set Application("RenderingApplication") = Nothing