Search code examples
iisasp-classic

Classic asp application_OnEnd and session_OnEnd events not working


I need to still work with classic asp and I faced with an existing application an issue with Application_OnEnd and Session_OnEnd events - i.e. the are not working. OnStart-events work normally. I do not have a clue what has caused OnEnd events from working; earlier on they used to work normally. My IIS version is 10. Has anyone faced this issue and found solution?

I experienced the same issue also on my remote server (shared hosting environment) with also IIS 10.


Solution

  • Based on the reply of user692942 there was older similar kind of question containing the solution, see: https://blogs.iis.net/lprete/session-onend-classic-asp-and-iis-7-0.

    Thus, the issue was due to a setting in applicationhost.config -file. There must be the following in order for OnEnd -events to work in global.asa:

    <system.webServer>
        <asp runOnEndAnonymously="false" />
    
    </system.webServer>
    

    This can be simply set by running the following from the command line (with admin rights):

    cscript.exe c:\inetpub\adminscripts\adsutil.vbs set w3svc/AspRunOnEndAnonymously false
    

    So, IIS 10 seems to be setting this true automatically causing the issue with OnEnd-events. Well, now we know the fix for it.