Home > Archive > ASP .NET > March 2008 > trapping asp.net session end
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
trapping asp.net session end
|
|
| dmalhotr@usa.net 2008-03-27, 7:35 pm |
| 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
| |
| Peter Bromberg [C# MVP] 2008-03-27, 7:35 pm |
| For InProc Session, the Session_End event in global.asax *is* the event that
is fired when a user Session has expired.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
"dmalhotr@usa.net" wrote:
> 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
>
| |
| Mark Rae [MVP] 2008-03-27, 10:31 pm |
| <dmalhotr@usa.net> wrote in message
news:836dfde5-aff7-4ea9-afdb-893e5f7c2b21@i29g2000prf.googlegroups.com...
> 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...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
| |
| siccolo 2008-03-28, 7:28 pm |
| On Mar 27, 3:34=A0pm, dmalh...@usa.net wrote:
> Hi,
>
> I would like to know if there was a way to trap a session timeout on
> an asp.net event. =A0What I mean is that I've set a session timeout in
> the web.config file. =A0What I would like to do is when that timeout is
> reached, I would like it to fire an event. =A0Is there some event in the
> global asax that could fire when the session normally ends. =A0I 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=3D"javascript" type=3D"text/javascript">
function ShowTimeoutWarning ()
{
window.alert( "Oh-ho!Session Expiring!" );
window.location.href =3D "your_start_page.aspx";
}
<%
if
( HttpContext.Current.Session["SessionTestVar"].ToString()!=3Dnull )
{
Response.Write( "setTimeout('ShowTimeoutWarning();', " +
( Session.Timeout *
60000 ).ToString() + " );" );
}
else
{
Response.Redirect("your_start_page.aspx", true);
}
%>
=2E.. more at http://www.siccolo.com/articles.asp
|
|
|
|
|