Revision: 13861
Updated Code
at September 4, 2009 17:08 by jink
Updated Code
private void AddKeepAlive() { int int_MilliSecondsTimeOut = 2 * 60 * 1000; /*2 minutes*/ //Math.Max((this.Session.Timeout * 60000) - 30000, 5000); string path = VirtualPathUtility.ToAbsolute("~/KeepAlive.aspx"); string str_Script = @"<script>(function(){var r=0,w=window;if (w.setInterval)w.setInterval(function() {r++;var img=new Image(1,1);img.src='" + path + @"?count='+r;}," + int_MilliSecondsTimeOut.ToString() + @");})();</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), UniqueID + "Reconnect", str_Script); } //[KeepAlive.aspx:] <%@ OutputCache Location="None" VaryByParam="None" %> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <%=now %> </html>
Revision: 13860
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 8, 2009 10:09 by jink
Initial Code
private void AddKeepAlive() { int int_MilliSecondsTimeOut = 2 * 60 * 1000; /*2 minutes*/ //Math.Max((this.Session.Timeout * 60000) - 30000, 5000); string path = VirtualPathUtility.ToAbsolute("~/KeepAlive.aspx"); string str_Script = @"<script>var refreshCount=0;if (window && window.setInterval)window.setInterval(function() {refreshCount++;var img=new Image(1,1);img.src='" + path + @"?count='+refreshCount;}," + int_MilliSecondsTimeOut.ToString() + @");</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), UniqueID + "Reconnect", str_Script); } //[KeepAlive.aspx:] <%@ OutputCache Location="None" VaryByParam="None" %> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <%=now %> </html>
Initial URL
http://www.codeproject.com/KB/session/Reconnect.aspx
Initial Description
Call AddKeepAlive() in Page_Load of the page that needs it. Change the path to the correct keep alive page. Page should disable caching, like in second code snippet.
Initial Title
ASP.net: Session timeout prevention (keep alive).
Initial Tags
aspnet
Initial Language
ASP