Application Variable dissappearing
-
Hello all, Not sure if anyone has seen or heard of this problem before, but it has me stumped and google has failed to help in my search for an answer so far... I am trying to use a couple of Application Variables on my site, but they keep disappearing. I am storing the values I want them to hold in a config table in an SQL Db, then on application start I fetch the config values and turn them into Application variables so that I don't need everyone connecting to the db each time they need to be used which is very frequently. I know making changes to the web.config file restarts the application, and that's not what's causing the problem. No class files are being changed or even pages updated, and yet the application variables just vanish, sometimes twice a day, sometimes once a week. I have written an admin page to reset the varibles so it can be done nice and quickly, but I can't seem to find out what the problem is, I only seem to get it on my live server, not my test one. it's a Win 2003 box and the sites .net 3.5 if that helps at all? Any help/advice would be appreciated. Thanks in advance mark
-
Hello all, Not sure if anyone has seen or heard of this problem before, but it has me stumped and google has failed to help in my search for an answer so far... I am trying to use a couple of Application Variables on my site, but they keep disappearing. I am storing the values I want them to hold in a config table in an SQL Db, then on application start I fetch the config values and turn them into Application variables so that I don't need everyone connecting to the db each time they need to be used which is very frequently. I know making changes to the web.config file restarts the application, and that's not what's causing the problem. No class files are being changed or even pages updated, and yet the application variables just vanish, sometimes twice a day, sometimes once a week. I have written an admin page to reset the varibles so it can be done nice and quickly, but I can't seem to find out what the problem is, I only seem to get it on my live server, not my test one. it's a Win 2003 box and the sites .net 3.5 if that helps at all? Any help/advice would be appreciated. Thanks in advance mark
Check if your application variable getting lost coincides with IIS worker process recycling. IIS Worker process gets recycled based on various conditions like number of inputs serviced, time to live, etc and is configurable. But, it has to be recycles no matter what. If this is the case then, it explains why you do not face this on your test server, since the no of hits on your test server is nowhere near what you get on the Live server. The solution for your problem would be to use a sliding expiration scheme to auto expire/refresh the data on a time bound/unavailability basis. Alternatively, you can also modify the get property of the application variable to check if the data is available and fetch it from the server if it is not available. Doing this would ensure that your application does not fail and there is no need for manual intervention. HTH! Have a Great Year ahead!