Instead of trying to handle it on the server, you may find it much easier to
handle on the client. I've seen this done at sites such as my bank, where
they warn me my session will end shortly unless I perform some action.
You can't really handle the popup server-side because the user may not even
be on the site anymore. Keep in mind, http is a stateless protocol and the
user is disconnected from the server the moment the browser finishes
requesting all the data for the page. That means there's really no user to
push data to such as a popup. Handling it on the client can be fairly easy
because you know how long the session timeout value is in minutes, and can
check that on the browser since the session will timeout at pretty much the
same time a script on the browser would determine that 20 minutes are up.
--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
- Show quoted text -
for example, I do it like this (within ASPX page)
<!--
------------------------------------------------------------------------------------
-->
<!-- //for user session timeouts: -->
<!-- warn user session is about to expire in 1 min -->
<script type="text/javascript" language="javascript"
src="errors.js">
</script>
<script language="javascript" type="text/javascript">
function ShowTimeoutWarning ()
{
window.alert( "...about to expire..." );
window.location.href = "../Default.aspx";
}
<%
//Session.Timeout =2;
if ( HttpContext.Current.Session["UserSession"].ToString()!
=null )
{
Response.Write( "setTimeout('ShowTimeoutWarning();', " +
( Session.Timeout *
60000 ).ToString() + " );" );
}
%>
<!--