clear cache after browser closed

  • Thread starter Thread starter Gene Ariani
  • Start date Start date
G

Gene Ariani

I currently create an cache item called 'skey' as follow. I need to clear
this cache when the client browser closes.

Is this possible?

Dim sKey As String = username + password
Dim sUser As String = Convert.ToString(HttpContext.Current.Cache.Get(sKey))
Dim SessTimeOut As New TimeSpan(0, 0, HttpContext.Current.Session.Timeout,
0, 0)
HttpContext.Current.Cache.Insert(sKey, sKey, Nothing, DateTime.MaxValue,
SessTimeOut, System.Web.Caching.CacheItemPriority.NotRemovable, Nothing)


Any direction is appreciated it.
 
Hi,

First of all you need to remember that WEB forms are stateless. What I
mean is that there isn't any connection between server side code and
page render to the client side. If you want to "make" something happened
on the server side you need to generate request to server side code. You
can catch onbeforeunload window client side event and generate request
to server side code using Iframe or XMLHttpRequest. On the server side
the calling page can clear the cache and end session.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
Back
Top