Global.asa fails on error on any of the page

I am new to the asp world. We have few database calls for updating user logout timings depending on the session exit call. Once there is any kind of error in one of the pages the global.asa file doesnt run correctly. IS this the normal behaviour or is it something else ?

please let me know
thanks
rons
LVL 7
rohanbairat3Asked:
Who is Participating?
 
RejojohnyConnect With a Mentor Commented:
no .. not possible .. u could write code in the windows_onunload or body unload event to trap when the form get unloaded .. but i do not think even this is fired when the browser is closed ...
0
 
justinbilligCommented:
Fix the erros on your pages then see if it happens anymore =)
0
 
waelothmanCommented:
any error in global.asa may stope the service for this site

you have to user on error resume
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
RejojohnyCommented:
what is the error that u get? what do u mean by, file doen't run correctly?
0
 
rohanbairat3Author Commented:
there are no errors on global.asa  .... i am talking about the asp application which is running. We have a data entry application and we tract the user logoff timings. So if a user accidently closes the browser then the global.asa updates the database depending on the session id of the user. Also the user count is maintained in Application variable which doesnt get subtracted.

Please help

thanks
rohan
0
 
RejojohnyCommented:
>>Also the user count is maintained in Application variable which doesnt get subtracted
where have u written the code .. under which method of globasl.asa  ...could u please post the code ...
0
 
rohanbairat3Author Commented:
Sub Session_OnEnd()
           Application.Lock()
        
  set FSO = Server.CreateObject("scripting.FileSystemObject")
    Set file = FSO.OpenTextFile("D:\wwwroot\logfile.txt", 8, True)
 file.WriteLine("----------------------SESSION ON End------------------------")
      file.writeLine("Session.SessionID is "&Session.SessionID)
 if  Session("FCValidUser") = "1" then      
  dim strApplication,strSQL, objConn,NoOfUsers

  'Check if the User is a FC Data Entry User

      file.writeLine("UserName is "&Session("UserName"))
      file.writeLine("Application(NoOfUsersLogged) is "&Application("NoOfUsersLogged"))
      
         If (IsEmpty(Application("FCRecordSet")) ) then
         Else
               strRECSET = Application("FCRecordSet")
               'Clear previous data entry value from session and application object
               'This will let other users use the current value if needed.
                  file.writeLine("RecordID is "&Session("RecordID"))
               if Session("RecordID") <>"" then
                   For i = 0 to UBound(strRECSET)
                         file.writeLine("strRECSET("&i&") "&strRECSET(i))
                         strSessionRecordId = Session("RecordId")
                        ' Need to implement Garbage Collection for this
                         if strRECSET(i) = strSessionRecordId then
                              strRECSET(i) = ""
                         End If
                   Next
               End If 'Session("RecordID")
                  'file.writeLine("Application(FCRecordSet) "&Application("FCRecordSet"))
               Application("FCRecordSet") = strRECSET
         End If

         cRFSFCUserConnection = "DSN=R;UID=someuser;PWD=somepass;"
         Set objConn = Server.CreateObject("ADODB.Connection")
         objConn.ConnectionString = cRFSFCUserConnection
         objConn.Open
         'Note the Logoff Time of the user
         strSQL = "UPDATE DataEntryLog SET LOGOFFTIME = '"&now()&"' WHERE  SESSIONID = '" & Session.SessionID & "'"
         objConn.Execute(strSQL)
         Set objConn = Nothing
      
         NoOfUsers = Application("NoOfUsersLogged")
            file.writeLine("NoOfUsers "&NoOfUsers)
         'Check the Number of Users Logged on. IF the USere are more than 1 then reduce the
         'NoOfUsers by1
         if (NoOfUsers > 1) then
             file.writeLine("Number of users"& Application("NoOfUsersLogged"))
         NoOfUsers = NoOfUsers - 1
             Application("NoOfUsersLogged") = NoOfUsers
              file.writeLine("After subtracting one Number of users "& Application("NoOfUsersLogged"))
         Else
           'IF all the FC users are Logged off Destroy the Application Objects
             file.writeLine("Number of users is less than or equal to 1"&Application("NoOfUsersLogged"))      
           Application.Contents.Remove("NoOfUsersLogged")
             Application.Contents.Remove("FCRecordSet")
             file.writeLine("After removing contents of application(NoOfUsersLogged) and application(FCRecordSet)")      
         End If
      
        

End If
0
 
RejojohnyCommented:
so what happens .. isn't log never written or just that the number of users doesn't get substracted .. and just curious .. shouldn't the path of the log file be d:/inetpub/wwwroot ... unless ofcourse u have another directory called wwwroot .. in that case, does the IUR_machinename user have read/write access to this directory?
0
 
rohanbairat3Author Commented:
the log get written all the time ..but it behaves funky ... sometimes it write sometimes it dows not
0
 
RejojohnyCommented:
so when r u checking whether anything has been written to the log file or not .. I beleive session_onend is not fired immediately when a browser is closed .. but it fires based on the session timeout set in IIS for ur site .. check i out .. u could make it to fire immediately with a "session.abandon" command .. but then when will call this if the user closes the browser without loggin out is going to ur next question ..
0
 
rohanbairat3Author Commented:
I know about the session time out thing... I checked the Event viewer to see if it has some problems ...

can i fire a session.abandon when browser is closed ????
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.