I separated all direct session interaction into a separate class and made it static, because I didn't want to create a new object several times. However, i wish to make sure that there are not concurrency issues or other wonky suprises.
Here is the code:
public static class HttpHelper
{
public static string Get(string key)
{
object value = HttpContext.Current.Request.QueryString[key];
return (value == null) ? null : value.ToString();
}
public static string Post(string key)
{
object value = HttpContext.Current.Request.Form[key];
return (value == null) ? null : value.ToString();
}
public static string Session(string key)
{
object value = HttpContext.Current.Session[key];
return (value == null) ? null : value.ToString();
}
public static void ClearSession(string key)
{
HttpContext.Current.Session[key] = null;
}
public static void StoreInSession(string key, object value)
{
HttpContext.Current.Session[key] = value;
}
}