Solved

Evaluate Global.asa file

Posted on 2002-06-20
12
252 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

16 Experts available now in Live!

Get 1:1 Help Now