Hi,

I'm using visual studio 2008 and it's built in development webserver, with C# as the codebehind language.

I'm trying to make a simple webapp in which you click a button which sets a session var (that part is working) and in the pageload
i'm checking to see if it's a postback and if the session is not null. problem is that every time the session is null.
I have done this successfully before with visual studio 2003 and on IIS.

Here is the relevant code:

protected void Button1_Click(object sender, EventArgs e)
{
Session["testvar"] = 25;

/*
if (Session["testvar"] == null)
Response.Write("s is null");
else
Response.Write("s is NOT null");

*/
}


protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
int x;

//x = (int)Session["testvar"];


if (Session["testvar"] == null)
Response.Write("test var is null");
else
{
x = (int)Session["testvar"];
TextBox1.Text = x.ToString();
}



}
}

I've changed in the web.config the state settings such as mode = "InProc" and timeout = "20"

but that didn't help.

Any help is appreciated.
Thanks

Hi,

Your code is working fine for me.

Are you checking your code in IIS on Windows XP(your development machine) or any Windows Server or the built-in web server comes with VS 2008?

Your code is working fine with VS 2008 with built-in web server and also VS 2008 with local IIS on Window XP.