
When connecting from Windows Vista or Windows XP Home to a Windows XP Professional SP3 machine via Remote Desktop, I was constantly bothered by timeout issues. I would get the following error message:
Session has been idle over its time limit.
It will be disconnected in 2 minutes.
Press any key now to continue session.
In addition to the error message, the computer running Windows XP Professional SP3 would periodically beep. However, the solution to this is to change the session timeout on the computer you are Remote Desktop to. Follow the step by step instructions below:
- Go to the Start Menu and click Run (or press the shortcut combination Windows+R).
- In the prompt, type gpedit.msc and click OK.
- In the left panel, navigate the hierarchical menu: Computer Configuration > Administrative Templates > Windows Components > Terminal Services > Sessions
- Double click the “Sets a time limit for active but idle Terminal Services sessions” property to open up the properties window.
- In the popup window, make sure the Enabled selection is chosen and the Idle Session Limit dropdown list is set to Never.
- Click Ok and close all windows and applications
- Reset the computer for the changes to take effect.
Since making this change, I can remote login to my desktop and leave the session idle overnight without having to worry about the Window machine beeping throughout the night.
It’s common practice to store certain values in session variables to allow for easy access of data between page loads. This is known as a Server Variable in C#. Assume a server variable name of “foo“. It would be accessed as:
string myValue = Request.ServerVariables.Get("foo");
If you get the following error message: The name “Request” does not exist in the current context, try the following:
string myValue = System.Web.HttpContext.Current.Request.ServerVariables.Get("foo");
Round trip database reads becomes an issue with large databases. You may notice this occurs in grid views. Each time the dataset is sorted or filtered, the default grid view needs to be data binded. In most cases, the data source is the database (sql statement or stored procedure). An easy way to prevent these round trips across page loads is to use a session variable. One important aspect to note is that session variables expire by default after fifteen minutes.
We are going to store a Boolean variable rememberMe in a ViewState. By storing the Boolean in a ViewState, rememberMe will retain its value across page loads. In this example, the boolean variable rememberMe will default to false. The variable rememberMe can be read to and from as if any public class variable.
public partial class _Default : System.Web.UI.Page
{
public bool rememberMe
{
get
{
object o = ViewState["rememberMe "];
return (o == null)? false : (bool)o;
}
set
{
ViewState["rememberMe"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
Again, it is important to note that session variables expire by default after fifteen minutes. If a default value is not assigned, additional logic is required to prevent unanticipated affects. This method is very effective when retrieving an extremely large number of records. You will immediately notice the first query will take the standard query time, but each subsequent action on the same dataset will be very quick.