Solved

Global.asa fails on error on any of the page

Posted on 2004-10-13
11
232 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:rohanbairat3
11 Comments
 
LVL 15

Expert Comment

by:justinbillig
ID: 12301445
Fix the erros on your pages then see if it happens anymore =)
0
 
LVL 5

Expert Comment

by:waelothman
ID: 12302330
any error in global.asa may stope the service for this site

you have to user on error resume
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12305432
what is the error that u get? what do u mean by, file doen't run correctly?
0
 
LVL 7

Author Comment

by:rohanbairat3
ID: 12321414
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
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12337405
>>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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 7

Author Comment

by:rohanbairat3
ID: 12339911
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
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12344884
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
 
LVL 7

Author Comment

by:rohanbairat3
ID: 12347862
the log get written all the time ..but it behaves funky ... sometimes it write sometimes it dows not
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 12347976
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
 
LVL 7

Author Comment

by:rohanbairat3
ID: 12425216
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
 
LVL 26

Accepted Solution

by:
Rejojohny earned 125 total points
ID: 12430591
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now