Forum Moderators: open
/LM/W3SVC/960089196/Root/global.asa, line 57
I get this when I click an "exit" button on my application.
this happens only sometimes. I can't seem to get it to happen on cue so I can fix it.
The line 57 is pointing to the bold line in the following SUB:
Sub Session_OnStart()
Session.Timeout = 20
Session("Start") = Now()
If Not rstActiveUsers.EOF Then rstActiveUsers.MoveLast
rstActiveUsers.AddNew
rstActiveUsers.Fields("id").Value = _
Session.SessionID
rstActiveUsers.Fields("ip").Value = _
Request.ServerVariables("REMOTE_HOST")
rstActiveUsers.Fields("browser").Value = _
Request.ServerVariables("HTTP_USER_AGENT")
rstActiveUsers.Fields("started").Value = _
Now()
rstActiveUsers.Update
End Sub
Basically, all I want to do in this is to capture open session information and the IP address of the current sessions so I can display them in a report as needed.
Perhaps there's a better way?
I really don't know much about the global.asa on Classic ASP.
Thanks.
Basically, all I want to do in this is to capture open session information and the IP address of the current sessions so I can display them in a report as needed.Perhaps there's a better way?
This data is stored in the IIS Log file anyway as a matter of course. Wouldn't you be better off parsing the log files to produce your reports?
Just a reminder - the Session_OnStart event operates outside the context of any page code. That is, things happen in this order:
- the browser requests an ASP page
- IIS determines that the requested page is an ASP page
- If no ASP session exists for the browser instance (no ASP session cookie is presented), IIS creates one which causes the Session_OnStart code to execute
- IIS begins processing the requested page
i do call Session.Abandon() on the exit button, and on the default.asp screen.
So if a user accidentally backs out of the program rather than clicks exit, the session is reset. We've had some issues with that.
rstActiveUsers is created as part of that same global.asa file, then populated as people login.
It's not the best solution I know, but I'm not that knowledgeable about the global.asa.
for parsing the session logs, it's just a basic text file, right? In a fixed format, so I might be able to do that.
The other wrinkle I thought was causing it, but it's not, is that upon login, I capture the username and time in the database for future reference and security. The exit button had a routine to write the logout time and screen to that same file.
I have a default "backdoor" password that I use sometimes and the code didn't write to the database if I used that password. I thought perhaps it was crashing due to not finding the original login to write, but that wasn't it.
The odd thing, is that nothing is affected. If I refresh the error screen, I do see the default home page.
Is there a better way to track open sessions than this one?
I don't think the log files will work, because some people stay on for longer than 20 minutes.
Thanks again for your help.
Seeing as you are using session.Abandon in two places , thats to be expected because your code attempts to move to the last record off an empty file
I dunno if your code as a whole is valid, but if you add a test for the BOF condition, this particuler error might vanish
Another thing you might find is that if session.abandon is executed anywhere on an asp file, all the session variables , those accessed before the session.abandon, and those after session.abandon, are flush
ASP.net is much much more stable