Groups | Blog | Home
all groups > asp.net caching > october 2004 >

asp.net caching : Application State Does not WORK! HELP!!


Garry McGlennon
10/27/2004 9:02:41 PM
Greetings

I've not having much luck with any type of cache. Currently I can't get
Application State to work. Here is the code I'm using to store something
into the Cache:

If System.Web.HttpContext.Current.Application("Framework.ReferenceData") Is
Nothing Then
System.Web.HttpContext.Current.Application("Framework.ReferenceData") =
New DomainValueGroupCollection
End If

Return
DirectCast(System.Web.HttpContext.Current.Application("Framework.ReferenceDa
ta"), DomainValueGroupCollection)

Now I've tried using the Cache object directly too same issue, it does
everything correctly for the postback in which the data is stored (ie once
stored I can retieve the data as many times as I like during the postback).
However on subsequent postbacks the data is gone! I had exactly the same
problem with Session State too, I have to revert to using SQL Server for
Session State storage which did fix the problem. I'm assuming Application
State is always stored in memory, which is what I want.

This is driving me nuts and so is the Session State issue too - I seem to be
having the Session state issue on many different machines too. Very very odd
stuff - this should be easy!!!!!

Any help very much appreciated

Garry Mc

Garry McGlennon
10/27/2004 9:36:53 PM
I've discovered another thing the following code in the Global.asax executes
during every postback. My understanding is that this is supposed to execute
only once per application startup.

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
' Some code here, which seems to execute during EVERY postback
End Sub

I hope this helps identify my problem.

Garry Mc

[quoted text, click to view]

Garry McGlennon
10/28/2004 12:00:31 AM
I've managed to track the problem down - it took several hours but it had
something to do with a resource file being accessed. Although the code
didn't complain I guess it did something bad.

If anyone else has issues with their Application restarting try putting a
break in the Application_End event and start removing bits until it starts
working again. It took sometime but I worked it out (had to be one of the
lowest parts of the code too!)

So I guess this is a solved problem...

Regards
Garry Mc

[quoted text, click to view]

AddThis Social Bookmark Button