Stop ASP.NET Session Timeouts

Yes you can stop session timeouts. There is a easy way that does not require AJAX calls or other such methods. I have tested this method on an ASP.NET Data Entry page and left it up for 4 hours, clicked save, and all was well.

Dealing with Session Timeouts in ASP.NET was always a pain. I came across a method by Primary Objects that is simple to implement and will not only keep the session alive but will keep the worker process alive on the server as well.

Summary: Use a page such as KeepAlive.aspx and place it in a hidden iFrame on a master page. Use the Meta Refresh on this page to post back to the server every 19 minutes to keep the user session alive and the work process up and running.

There are three parts to this method.

1. Create a SessionAlive.aspx page and include this in an IFrame of your master page.


2.  An optional part of this process is to display the last status refresh time on the status bar in the browser. This is good for testing purposes.


3. In the code behind of the KeepAlive.aspx page update the meta refresh tag after page loads for under 20 minutes. The typical session timeout.

The orignal posting of the solution can be found at Primary Objects.

Attached is the code for this solution. (1.75 kb)

Objects is in a Zombie State

Ok, this is the funniest error message I ever saw. I have VS 2010 up and debugging an application. I also had a .NET 2.0 site running that I shut down. There were two worker processes running on my machine. I killed various apps such as IE but they all still showed up in the task bar.

So I thought, the darn worker process must be freezing up my machine. I killed it and got the strange Zombie Message below.


ASP.NET - Raise Event on Parent Page from User Control

I had a user control embedded in an ASPX (parent) page as a hidden layer. The control was placed inside of a panel control that was hidden. The parent page would load an show the user control

Once the user completed the work they clicked "Close Window" that would raise an event on the parent page, and  the parent page would hide the hidden layer.

1. User Control (ASCX): Add the following delegates and events

// Delegate declaration  
public delegate void OnButtonClick(string strValue);          
// Event declaration  
public event OnButtonClick btnHandlerEditAccount;

2. User Control (ASCX): Button close event will raise btnHandlerEditAccount causing the parent page to hide the panel with the user control.  

protected void BtnCloseWindow_Click(object sender, EventArgs e)
   //Make the parent close the window
   if (btnHandlerEditAccount != null) btnHandlerEditAccount(string.Empty);

3. Parent Page: Handles btnHandlerEditAccount from the user control.

//Event Handlers to close windows from user controls (place in Page_Load)
UCEditAccountInfo.btnHandlerEditAccount += new EditAccountInfo.OnButtonClick(UCEditAccount_btnHandler);

//Syntax of item above: UserControlName dropped on the page += new Class.NameOfActualUserControl.OnButtonClick(handler created in step 1)

/// Handle the Window Close on the Edit Account User Control
protected void UCEditAccount_btnHandler(string strValue)
     PnlGrid.Enabled = true;
     PnlAccountEdit.Visible = false;