views:

213

answers:

2

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.

A: 

Ok, I just added this to the web.config:

<sessionState cookieless="true" />

and that worked but there must be another way to solve this.

Loki Stormbringer
A: 

Something is different with the configuration for these two machines, no doubt about it.

So you've done a diff on the web.config for these two machines and they're identical? Not just a cursory look, but run it through a diff program? (I like CompareIt!)

If that's the case, you need to go up the rest of the configuration tree... master web.config in the ASP.NET install directory... Then machine.config.

You'll find something.

Bryan