Get Value from Session Variable in C#
by Victor | June 6, 2008 in C# | No Comments
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");




