?
Solved

Evaluate Global.asa file

Posted on 2002-06-20
12
Medium Priority
?
291 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 200 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:Michel Sakr
ID: 7097890
>file not closed.
object not released.

indeed.. this can lock the application for ever so asp files will not be processed..
0
Industry Leaders: 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!

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

649 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