Using global callback function with cache object

N

NWx

Hi,

I' trying to implement a callback method when a cache object expires
I want to do this to automatically logout user after a timeout (for demo
purposes)

My thought is, when user logon, create a cache object which expires after,
let's say, 15 minutes, and in that moment, to direct user to a page telling
the time to run demo app was expired.

I found an example on how to do this, but it involves working on the same
page, because the callback function is declared as private void in the page
who register the cache object.

Can I do this, using a shared function instead a private one?

What I want it to execute the callback method no matter what page user is
in, when timeout expires.

Regards
 
J

Jerry III

You're definitely trying to use the wrong tool. Just create an encrypted
cookie with the users expiration time and log them out once their time
expires. Forms authentication can do this for you automatically. Cache is
not the right object to do this with (your object can get released at any
time, if you understand how the Cache object works you would know that).

Jerry
 
N

NWx

Hi,

Thanks for reply
Actually I used an approach like this, not with the cookie, but with a cache
object
I created a cache object which stores the date/time when the user must be
logged off
In my header Custom control's Load event, I check that object against
current datetime, and logoff when necessary.

My thought about callback from cache was to logoff EXACTLY when time was
expired (because with current approach, if user don't load another page for
a longer time, he won't be logged off)

Regards
 
J

Jerry III

Since you're cross-posting this into the asp group I assume you're talking
about a web application. There is no such thing as logoff in a web
application, HTTP is a stateless protocol. You cannot logoff user at a
certain time since you, as a server, cannot do anything but react to users
requests. If the user does not send a request there's nothing you can do.

As for using the Cache object for this - why would you want to logoff users
when you run low on memory (because that's when the Cache will start
releasing objects no matter what their expiration time)? It makes absolutely
no sense to use Cache here (or think that you can control the client from a
web application).

Jerry
 
C

Chad Z. Hower aka Kudzu

Jerry III said:
talking about a web application. There is no such thing as logoff in a
web application, HTTP is a stateless protocol. You cannot logoff user at

True - but when you use the session object in ASP.net, it does have an
expiration. And if you know the user is done you should use its Abandon
method.
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top