I have been using session variables in my asp.net application for passing the next property:
[DefaultValue(true)]
public bool IsModificationMode
{
get
{
return (bool)Session["ModificationMode"];
}
set { Session["ModificationMode"] = value; }
}
In the PageLoad, I set it’s value.
Now after the Postback, I am losing it’s value having a a NullReferenceException
I upvoted @stacknewbee because I agree with his idea of the application pool self-recycling. As a solution, try uncoupling the session state from the w3wp.exe process by changing the web.config entry from InProc to StateServer:
Keep in mind that the server service ASP.Net State Server must be started.