balaweblog
balaweblog

Reputation: 15470

Renew ASP.net Session after the default timeout

I need to renew my old session if the session timeout exceeds the default 20 mins. Is there any session renew concepts in ASP.net?

Upvotes: 1

Views: 5984

Answers (4)

DilbertDave
DilbertDave

Reputation: 3446

I had a similar issue a little while ago and found this article very helpful - at least in overcoming part of the problem.

I also added the following line into the defribulator page to prevent caching and it works fine for us.

Basically it performs an invisible postback (renewing the session) just before it is about to expire - we actually do it a little earlier than that.

Hope this helps but i can dig out some of the code I used if you want to have a look.

Upvotes: 3

Jonathan Lonowski
Jonathan Lonowski

Reputation: 123453

Not really. At least, not post-expire.

The most common, that I've seen, is to send an Ajax "PING" request periodically. Just something to access the server and restart the timeout count for the session.

Jeff wrote about this a while back.

Upvotes: 1

annakata
annakata

Reputation: 75794

If you're renewing the session after it expires and when that one expires you'll renew it what you're really doing is not having it expire at all.

Why not just extend the session period beyond the 20 minutes in the first place? Is it conditional?

Upvotes: 3

MK_Dev
MK_Dev

Reputation: 3333

One way to do this would be to write a JS function that fires at some interval. This function would make an asynchronous call (AJAX) to the server to keep the session alive. This way session will not timeout. This is one way that I am aware of and have seen used.

Upvotes: 1

Related Questions