I am using following code for session management.
public class MyClass
{
public static int SomeProperty
{
get { return (int)HttpContext.Current.Session["MyID"]; }
set { HttpContext.Current.Session["MyID"] = value; }
}
}
Problem is once in a while I get "Object reference not set to an instance of an object." on get { return (int)HttpContext.Current.Session["MyID"]; }
, although I know for fact that MyID was been set in session. Seem to me that for some reason that session is destroyed. Any ideas why that can happen?
I have nothing defined for session state in web.config which leads me to believe that this is a case of InProc server