views:

535

answers:

3

I came across a weird behavior today w/ my web application. When I navigate from a page to another, I lose one particular session variable data.

I'm able to launch the app in firefox and able to see that the session data is not lost.

I use Response.Redirect(page2, false) to redirect to another page.

Below code was used to track session variables

System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\test.txt", true);
for (int i = 0; i < Session.Count; i++)
{
 sw.WriteLine(Session.Keys[i] + " " + Session.Contents[i]);
}
sw.Close();

Can anyone help me in this? Any help is appreciated.

A: 

See http://stackoverflow.com/questions/2306147/ie8-losing-session-while-firefox-works-fine for a similar problem.

Obalix
I think I'm a bit unclear.My Page2 needs that particular session variable data to populate a gridview. With IE, I see the gridview to be blank and with firefox am able to see the grid populated.To verify session variables and its contents, I just wrote a sample code to write down the session variables and contents into a text file.
Ananth
My question describes a similar behaviour. On postback the session is reset and all session variables are lost. In firefox everything works fine. As it stands the theory is that loading the scrips from a server which is different from the server from which the results a posted to, causes the session to be reset.
Obalix
I was able to overcome the behavior by setting cookieless attribute to true in web.config file. I'm not sure why I see the behavior when cookieless is set false. Anyway thanks for your input guys!
Ananth
A: 

Are you developing in a web farm / web garden environment?

code4life
No am not developing in web farm/ web garden environment
Ananth
A: 

Try using the state server mode. Depending on how your application pool is configured and your deployments the default in-process mode can be unpredictable.

Maxwell Troy Milton King
I can try state server mode but since this code (with InProc mode) was for a long time and also present in 3 other environments, I can't change it. But, I have no idea why this issue shows up now
Ananth
What about cookies then? Watch it with fiddler and/or watch the session id for changes.
Maxwell Troy Milton King