Asp – Handle the End Request event in class ASP

asp-classiciis

In ASP.NET there is the Application_EndRequest event in global.asax. In classic ASP however there is no such equivalent event in global.asa

Is there any other built in way of handling the end request event, or any way of somehow hooking into IIS to accomplish the same thing?

Best Answer

We use a particularly twisted technique to execute code after the request has completed. Consider the following snippet:

Class EndRequestHandler
    Sub Class_Terminate()
        '' Handler code goes here
    End Sub
End Class

Set EndRequestHandlerInstance = New EndRequestHandler

When the request ends, ASP unloads all of the global variables, including EndRequestHandlerInstance, which calls it's Class_Terminate method. If you place this into an include file that's used by every page on the site, it should serve as your global end request handler.