I have an ASP.NET web application that takes user input across several forms. Sort of like a wizard. On the first form, the user enters information then clicks the "Next" button. In the Click event of the button I save some information to the Session object (via Properties in the Master page). I then Redirect to the next page.
Here is an example of what I am doing:
In the fist page...
protected void NextButton_Click(Object sender, EventArgs args)
{
//Go to the next form
Master.SessionVal1 = Value1;
Master.SessionVal2 = Value2;
Response.Redirect("~/TheNextPage.aspx", false);
}
In the MasterPage.cs..
public long Value1
{
get { return (long)Session["Value1"]; }
set { Session["Value1"] = value; }
}
public long Value2
{
get { return (long)Session["Value2"]; }
set { Session["Value2"] = value; }
}
Pretty basic stuff. When I run this in debug mode in VS2008 it works perfectly. When I push this to a test server (IIS7) I get NullReference exceptions when I try to access Value1, Value2, etc. which is stored in the Session object.
UPDATE: I have discovered that if I migrate the code to one server I get the problem as described above. BUT, if I promote to another server it works as expected.
Both servers are Windows Server 2008 with IIS7. I have looked at the application pool settings and the state management settings and I do not see any differences.