By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,130 Members | 2,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,130 IT Pros & Developers. It's quick & easy.

How can I find when an ASP.NET session has expired?

P: n/a
I have an ASP.NET application that is using forms authentication and I want to know when a session has timed out

I have read quite a lot of posts here about this but no-one seems to have to same issue
Rather than telling the user that a timeout has occured I want to know on the server so I can call a stored procedure

Adding code to Session_End in global.asax doesn't help because this only gets called when Session.Destroy is called and not when a session simply dies

Does anyone have any ideas?

TI

David Popeck
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I don't know whether it could work or not.

Put a timer object in the a session variable with the same timeout of
the session.

On each request stop the timer in Page load and start at page unload.

Place the code to handle the request in a class.

I've thought of this and written it Without testing, so itmight be just
rubbish.

HTH

Stefano Mostarda MCP
Rome Italy

David Popeck wrote:
I have an ASP.NET application that is using forms authentication and I want to know when a session has timed out.

I have read quite a lot of posts here about this but no-one seems to have to same issue.
Rather than telling the user that a timeout has occured I want to know on the server so I can call a stored procedure.

Adding code to Session_End in global.asax doesn't help because this only gets called when Session.Destroy is called and not when a session simply dies.

Does anyone have any ideas?

TIA

David Popeck

Nov 18 '05 #2

P: n/a
Oh no, on the Page_Load sub routine of a each page just check
Session.IsNewSession variable if it returns true, you know the session
expired.

example:

if (Session.IsNewSession == true)
Server.Transfer("default.aspx");
"Stefano Mostarda" <st**************@fastwebnet.it> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I don't know whether it could work or not.

Put a timer object in the a session variable with the same timeout of
the session.

On each request stop the timer in Page load and start at page unload.

Place the code to handle the request in a class.

I've thought of this and written it Without testing, so itmight be just
rubbish.

HTH

Stefano Mostarda MCP
Rome Italy

David Popeck wrote:
I have an ASP.NET application that is using forms authentication and I want to know when a session has timed out.
I have read quite a lot of posts here about this but no-one seems to have to same issue. Rather than telling the user that a timeout has occured I want to know on the server so I can call a stored procedure.
Adding code to Session_End in global.asax doesn't help because this only gets called when Session.Destroy is called and not when a session simply
dies.
Does anyone have any ideas?

TIA

David Popeck

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.