goofy global.asa

  • Thread starter Thread starter Giorgio
  • Start date Start date
G

Giorgio

Hi all,
i have a problem with a website where i use asp 3 and a global.asa in the
root.
In global.asa i use some aaplication variables which contains strings, such
as: Application("str1")="text".
Sometimes (even if i dont change the code) application variables becomes
null
To solve the problem i delete from server my global.asa and upload new one
(with same code inside)
Provider says their servers are all right
how can i fix it?

Thanx
 
What did they tell you in the ASP newsgroup...?

which one?
i posted to an italian ng but i didn't get any answer
is there any other?
 
If your Application variables are "evaporating" occasionally,
you can reset them, and make sure they do exist, by using an include file:

Include this "test_app_vars.inc" in your pages :

<% language="vbscript" RUNAT=SERVER %>
<%
If Application("str1") = "" Then
'this runs f the variables have been lost
Application.Lock 'Lock App while you reset
Application("str1") = "whatever that variable is"
Application("str2") = "whatever"
Application("str3") = "something else"
Application.Unlock
End If
%>

That will assure you that even if the variables are "lost", by anything your
provider has misconfigured, your variables will be available for your use
in any page in which you include "test_app_vars.inc".




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
That will assure you that even if the variables are "lost", by anything
your
provider has misconfigured, your variables will be available for your use
in any page in which you include "test_app_vars.inc".

Thanks (for the ng address also).
Doing so, i have to put the include in any page, so i could even not use
global.asa anymore, but include file only.

The strings are connection strings to several databases, so i use these
strings in a lot of pages and global.asa was so usefull cause in the pages i
don't have to write code
 
Are you setting this variable in the Application_OnStart event?
I suspect your application was restarted and that is why
you are losing the value. This event fires when the application
starts back up.

Thanks.
Yes, i set them in that event.
Does not this event fire when any page is accessed first time by first
client?
So, also if it had been "resetted", when first client access a page the
string should be avalaible, isn't it?

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Option Explicit

Sub Application_OnStart
Application("str1") = "text"
End Sub

Sub Application_OnEnd
'end
End Sub

Sub Session_OnStart
'start
End Sub

Sub Session_OnEnd
'end
End Sub
</SCRIPT>
 
Back
Top