trapping asp.net session end

D

DMH

Hi,

I would like to know if there was a way to trap a session timeout on
an asp.net event. What I mean is that I've set a session timeout in
the web.config file. What I would like to do is when that timeout is
reached, I would like it to fire an event. Is there some event in the
global asax that could fire when the session normally ends. I need to
capture this to call a corresponding function during time lapse
timeout.

:D
 
M

Mark Rae [MVP]

I would like to know if there was a way to trap a session timeout on
an ASP.NET event.

Session_End will fire when an inproc session terminates.

N.B. closing the browser or navigating to a different website will *NOT*
cause the session on the webserver to terminate...
 
S

siccolo

> Hi,

I would like to know if there was a way to trap a session timeout on
an asp.net event. *What I mean is that I've set a session timeout in
the web.config file. *What I would like to do is when that timeout is
reached, I would like it to fire an event. *Is there some event in the
global asax that could fire when the session normally ends. *I need to
capture this to call a corresponding function during time lapse
timeout.

:D

or....if you have a session variable, let's call it "SessionTestVar",
then, you can do something like this:

<script language="javascript" type="text/javascript">
function ShowTimeoutWarning ()
{
window.alert( "Oh-ho!Session Expiring!" );
window.location.href = "your_start_page.aspx";
}
<%
if
( HttpContext.Current.Session["SessionTestVar"].ToString()!=null )
{

Response.Write( "setTimeout('ShowTimeoutWarning();', " +
( Session.Timeout *
60000 ).ToString() + " );" );
}
else
{
Response.Redirect("your_start_page.aspx", true);
}
%>



... more at http://www.siccolo.com/articles.asp
 
Last edited by a moderator:

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top