Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Evaluate Global.asa file

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
mgfranz
Asked:
mgfranz
  • 5
  • 3
  • 2
  • +2
1 Solution
 
Göran AnderssonCommented:
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
 
jkunalCommented:
seconds greenghost

error handling missing.
file not closed.
object not released.
0
 
Michel SakrCommented:
>file not closed.
object not released.

indeed.. this can lock the application for ever so asp files will not be processed..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mgfranzAuthor Commented:
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
 
mouattsCommented:
Is this hosted on ntwebhost by anychance?
0
 
mgfranzAuthor Commented:
Nope, a Verio sub called NexPoint.net
0
 
mouattsCommented:
what error message was displayed in the log file for the .asa?

0
 
mgfranzAuthor Commented:
I'll find out.
0
 
jkunalCommented:
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
 
mgfranzAuthor Commented:
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
 
mouattsCommented:
Thanks mgfranz I'll pass that on to my ISP.
0
 
mgfranzAuthor Commented:
Thanks for your help...
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now