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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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 said:
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
gets called when Session.Destroy is called and not when a session simply
dies.
 
Back
Top