Solved

Evaluate Global.asa file

Posted on 2002-06-20
12
268 Views
Last Modified: 2012-06-21
One of my hosting companies sent me a copy of a global.asa file that is causing one of there servers to not serve .asp files, (html files still process), anyone care to comment on it?

-------------------- start --------------------------
<script language=VBScript runat=Server>

Sub Application_Onstart

Dim TempArray(15)
Application("visits") = 0
Application("active") = 0
Application("lastaccessed") = Now
Application("lastloggedon") = Now
application("lastloggedonuser") = "" 

application("Chatters") = ","
Application("Talk")=TempArray
Application("TPlace")=15

End Sub

Sub Application_OnEnd

End Sub

Sub session_onstart

session.timeout = 120
application.lock
            Application("lastaccessed") = Now
application.unlock
application.lock
            Application("visits") = Application("visits") + 1
application.unlock
application.lock
            Application("active") = Application("active") + 1
application.unlock

End sub

Sub Session_OnEnd
application.lock
        TempArray=Application("Talk")
        TempArray(1) = Temparray(2)
        TempArray(2) = Temparray(3)
        TempArray(3) = Temparray(4)
        TempArray(4) = Temparray(5)
        TempArray(5) = Temparray(6)
        TempArray(7) = Temparray(8)
        TempArray(8) = Temparray(9)
        TempArray(9) = Temparray(10)
        TempArray(10) = Temparray(11)
        TempArray(11) = Temparray(12)
        TempArray(12) = Temparray(13)
        TempArray(13) = TempArray(14)
        TempArray(14) = Temparray(15)
        TempArray(15)= "Citizen " & session("name") & " has logged out."
            strfilename = "D:\html\users\xyz\html\database\chatlog.txt"
            set objfilefso = CreateObject("Scripting.FileSystemObject")
        set objfilets = objfilefso.openTextFile(strfilename,8)
            Application("chatters") = replace(application("chatters"),"," & session("name") &",", ",")

            Application("Talk")=TempArray
            Application("active") = Application("active") - 1
application.unlock
end Sub

</script>

----------------------- end --------------------------

I don't particularly care for the use of the global.asa, and I really don't like calling FSO with Session_OnEnd.

The only real bit of information I can decypher from the faulting site is that the asa application objects are being referenced from a .pl script.  I did find an article on MS, http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q300883 that touched on the CGI issue, but the error log states that the .asa file is causing the problem, not the CGI.

Thanks,
0
Comment
Question by:mgfranz
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 50 total points
ID: 7097562
I am somewhat puzzled about the code in Session_OnEnd. It opens a file for appending, then it doesn't write anything to it... it doesn't even close the file.

Check the permission for the file. If they are not sufficient, the script will end while the application is still locked. The documentation says that if left locked, the application will be unlocked when the asp page ends or times out. I'm not certain in what extent that applies to global.asa...

So, there are some things you can do to increase the stability:

- Dimension the variables used in Session_OnEnd. That makes them local to the sub. I don't feel comfortable having global variables in global.asa... especially not if one of them is a (still open) file...!

- Open the file outside the application lock. If the file operation fails, at least there is no risk of leaving the application in a locked state.

- Close the file!

- Even better would of course be to add proper error handling when opening the file. Then you can also handle the (maybe unlikely, but still...) event that the file is already opened by another session running Session_OnEnd.
0
 
LVL 4

Expert Comment

by:jkunal
ID: 7097786
seconds greenghost

error handling missing.
file not closed.
object not released.
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 7097890
>file not closed.
object not released.

indeed.. this can lock the application for ever so asp files will not be processed..
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 18

Author Comment

by:mgfranz
ID: 7099287
Thanks to everyone, I missed the open object not being closed...

Since this .asa file belongs to some other web-site, the hosting company will have to recommend the changes to the client, until then the .asa has been suspended.

One more reason to not rely on the .asa for Session_OnEnd calls...
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7099341
Is this hosted on ntwebhost by anychance?
0
 
LVL 18

Author Comment

by:mgfranz
ID: 7099343
Nope, a Verio sub called NexPoint.net
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7100299
what error message was displayed in the log file for the .asa?

0
 
LVL 18

Author Comment

by:mgfranz
ID: 7102199
I'll find out.
0
 
LVL 4

Expert Comment

by:jkunal
ID: 7102655
you never know how many connections have they left open in the asp files.

Once had the same problem, ppl developed a site and followed no pactice, had to restart the sever every 2nd day. No connection or recordset was ever closed.
0
 
LVL 18

Author Comment

by:mgfranz
ID: 7104489
Actually since I implemented a fix on the .asa file, the host has not had to restart the server since Thursday, they use to have to restart it every morning...

The error message was non-descript really, it just said, "IIS cannot write to the log file, ..." and "The global.asa file cannot open temp file..."
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7104945
Thanks mgfranz I'll pass that on to my ISP.
0
 
LVL 18

Author Comment

by:mgfranz
ID: 7114854
Thanks for your help...
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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