1

My question has to do with grabbing all the active users on my site. Below are the specs:

  • IIS Version: IIS 8.5
  • Server: Windows Server 2012 R2
  • Root folder: D:\Sites\Default\WWWRoot
  • Site Directory: D:\Sites\Default\WWWRoot\Website

Website is the directory where all the pages are stored. This is also the page that is listed as the Default App Pool in IIS. Classic ASP is the default language we are using.

Recently, my manager asked that we grab the active users currently hitting our site on the index of the page and display it.

So I made a file called Global.asa in the WWWRoot Folder (not the Website directory) and this is the contents of the asa file:

<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> 
Sub Application_OnStart 
    application("activevisitors")=0 
End Sub 

Sub Application_OnEnd 
End Sub 

Sub Session_OnStart 
    application.lock 
    application("activevisitors")=application("activevisitors")+1 
    application.unlock 
End Sub 

Sub Session_OnEnd 
    application.lock 
    application("activevisitors")=application("activevisitors")-1 
    application.unlock 
End Sub 
</SCRIPT>

And in the Websites directory where all the site pages are stored, I have an index.asp file that has the below added:

There are <% response.write(application("activevisitors")) %> active visitors

When I load index.asp, it gives me "There are active visitors." but no numbers or count like its supposed to do. Here are my questions

  • Should Global.asa be in the WWWRoot folder (currently located) or the Websites folder (where index.asp located)
  • Does IIS need to be configured to allow .asa files? I noticed in Request Filtering the .asa is False for allowed.
  • Is the code correct? I even made a dummy asp page to see if just displaying the counter will work but it doesn't either.
  • Confirmed ASP pages
  • Does the ASA code look correct?

I have looked via google search and around here, nothing could give me the help that I need. I am hoping someone here could provide some direction. Greatly appreciate it.

jrp1982
  • 113
  • 2
  • 7
  • Unless the Application Pool is set to never recycle this approach is pointless, because the minute the Worker Process is restarted your `Application` object is reset along with any values defined within it. – user692942 Nov 30 '16 at 00:00
  • 1
    But to actually see any value returned from this *(however futile the approach)* you would need to make sure ASP Sessions are enabled in the ASP configuration in IIS for the Web Application and that the `global.asa` is located in the root of that Web Application. In your example you have the website sitting in the Default Website root folder, if your website sub folder is configured as a Web Application this is where the `global.asa` should be located. – user692942 Nov 30 '16 at 00:03
  • 2
    Thank you! So Enable Session State is set to True and the Global.asa file is now located in the website directory which is also the app pool in IIS. I will give it a try. Thanks again – jrp1982 Nov 30 '16 at 12:41
  • 2
    This worked for me. Thank you Lankymart. The worker processes do clear once the page is processed, so I think what you are getting at is that the information displayed will be inaccurate. But here is the issue. We have pages that take about 5-10 seconds to load due to the db connections they are querying, causing worker processes to queue up. Not sure if this is an issue because they clear once those pages are loaded. But it raised a concern for my manager and we need a way to monitor whats going on. We have about 5k hits a day which is big for a small page like ours. – jrp1982 Nov 30 '16 at 13:08
  • That's fine glad to help. Good luck with your investigation. – user692942 Nov 30 '16 at 13:10
  • yes, all your code is correct – Zam Dec 05 '16 at 08:55

0 Answers0