0

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

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ramesh S
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.