Reputation: 2785
So In Default.master.cs PageLoad I have the following:
contObj = Session["Contributor"] == null ? null : (Contributor)Session["Contributor"];
if (contObj == null)
{
Session["Contributor"] = new Contributor
{
ID = id,
Name = name,
Email = email
};
}
In Default.aspx.cs I'm trying to get the object by doing this on a button click event:\
contObj = (Contributor)Session["Contributor"];
However this is causing the following exception! object reference not set to an instance of an object.
I don't see what I'm doing wrong. Could you please elaborate?
Thanks!
Upvotes: 0
Views: 134
Reputation: 148180
Make sure that your EnableSessionState="true" in the page tag of default.aspx
Upvotes: 2