[CACHE] Remove an Item on exiting application

T

teo

I have an object stored in the Page.Cache.
(its name is the SessionId number).

I'd like to remove it from the Cache when the user close
or abandons 'mySite.aspx' page
(when he closes the browser, when he jumps to another site,
if the connection is broken, if an Error occur and the user is
istantly redirected to another page ...)

How to detected all this circumstances?

I used the Unload and then the Dispose events of the Page object,
but the first is continuosly fired (at every postback)
and the second is never fired,
so they seem to be both unuseful.
 
K

KJ

Hello Teo,

You've happened upon a common problem in web application programming
that has no reliable solution. Others may suggest using the Abandon
event of the Session object, but this too has its quirks. Perhaps you
can simply let the object in the Cache expire, or just overwrite it
when appropriate?
 
K

KJ

Sorry Teo, I meant to refer to the Session OnEnd event (not the Abandon
method). You can handle this event, but only once the session times
out. The server cannot know what the user does after the content has
been served (especially re the closing of browser windows). All the
server knows is when the last request was made from a client with a
particular session id.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top