Forum Moderators: open

Message Too Old, No Replies

global.asa problem

odd error message

         

txbakers

3:23 am on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just migrated to a W2003 server and I'm starting to get the EOF/BOF error on my global.asa file:

/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.

mrMister

11:59 am on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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?

txbakers

12:06 pm on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, because the logs capture logins for the whole day.
I just want a list of currently open sessions.

mrMister

1:40 pm on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your sessions last 20 minutes, then just parse the last 20 minutes of logs.

vite_rts

1:57 pm on Aug 10, 2006 (gmt 0)

10+ Year Member



Just a thought, you are not testing for a BOF condition in your code,

surely if the user you test for does not exist, your application must crash because off the BOF condition.

aspdaddy

4:31 pm on Aug 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What error do you get? Its strange you get it when clicking exit, when the code is contained in the session on start.

Are you calling session.abandon on the exit button?

mattur

10:25 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've always avoided using global.asa at all, after experiencing unreliable, unpredictable behaviour with it.

Perhaps you could re-write your code to use an include file on every page? Check if the current session is logged, if not log it, etc?

john_k

10:37 am on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where is rstActiveUsers created?

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

txbakers

12:43 pm on Aug 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks everyone.

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.

vite_rts

1:00 pm on Aug 11, 2006 (gmt 0)

10+ Year Member



That error you are getting is usually because the query has come up blank, i.e. a BOF condition,

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