Session Object Not Returning On Page Redirect

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!

Answers


Make sure that your EnableSessionState="true" in the page tag of default.aspx


Need Your Help

Database design for storing facebook friends list + Device Addressbook

c# php sql-server facebook database-design

How would you design a database to meet the following two requirements

is there a way to disable message map handlers during runtime, in mfc?

c++ mfc

BEGIN_MESSAGE_MAP(CGadgetStandardDialog, CStandardDialog)