Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application variables

Status
Not open for further replies.

lwfg

Programmer
Feb 9, 2009
52
US
I am assigning application variables. THey persist for a while, even between browser sessions, but after 45(?) minutes or so, it seems like the variable is still there but has no value. For ex.,
response.write("*"+application("testav(1)")+"*") will return the first thing in an array testav, *2*, but later it will just show up as **.

What can cause this?
 
If the application pool is restared, then the values will be lost. For example, if you created or modify a file through code,or manually in the web itself, the app pool will be reset and all values lost.
 
What types of values are you trying to store? Do they need to be available to everyone using the application? If that is the case then you should probably use the Cache object instead.
 
try to avoid application scope variables. they only create problems, as your are encountering.

I found using containers like structuremap and windsor eliminate the need of global scoped objects.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you both.

jbenson001: Other than the program I'm editting, I am not creating/modifying files. LIke you said, what gets lost are the values - no error says the variable isn't defined or declared.

*
Could the application pool be updating automatically on the server I am testing on?
*

THe data is strings and dates from code tables used by everyone. I want to query tables only when a flag's set to TRUE and then store the data in arrays. THis would reduce querying by a very large amount.
The flag used to be cache type but that was getting "lost" too but if I remember right, the whole variable or its declaration was disappearing, not just its value.

jmeckly:
I will look those things up.
 
Stick with using the Cache object. Cache will expire if depending on if it is absolute or sliding expiration. Cache will also be affected by the app pool. You will have to find out what is causing it to reset.
 
Cache, Application, and Session variables are all disappearing on that machine. I will ask the person responsible for the server about the application pool etc.

On another machine, one with Visual Studio 2008, I have not seen Application or Cache vars disappear yet. But, I cannot get the Session kind to work - I assign a value but cannot display it - nothing shows up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top