Keep ASP.net Session Alive Indefinitely

This article from The Code Project gives instructions on how to set up your ASP.net project so that as long as the user is logged in with the browser set to your site, the page will automatically refresh a few second before the session will expire (and will continue to do so indefinitely, as long as the user remains on your site).

The best part is that it is just two lines of code:

private void Page_Load(object sender, System.EventArgs e)
{

Response.AddHeader(“Refresh”, Convert.ToString((Session.Timeout*60)-10));

}

Read about The Session Defibrillator for more implementation information.

Tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *