views:

172

answers:

2

Hi Hi, I have a really strange problem to do with session variables.

I have an asp.net page that sets a few session variables. On my development machine (localhost), I do a postback and the session values are still populated.

When I Reload the page by clicking on the url bar and pressing enter the session variables are still there.

However when i deploy this page to a webserver, the page still retains the session values when doing a postback, but as soon as i click the url and press enter the session values are lost (where the ispostback = false)

But when i press the refresh button the session variables are present (but i do get a popup warning me that the page data needs to be resent!)

i am running IE 7, and the webserver is iis6 what am i doing wrong?!

please help x

A: 

Sounds like the webserver is not configured to use session state.

Make sure your web.config has the correct <sessionState> section, with the mode being InProc:

<sessionState mode="InProc" />
Oded
Hi Oded, i use the same web config file for the development and the webserver machines. Does the asp development server do the <sessionState mode="InProc"/> automatically for me? I'll check the web config when i can log back into my corperate network. thank you ;)
Hannah
+1  A: 

What session state provider are you using? The default is InProc, whereby sessions are stored in the asp.net worker process. This means session state can be lost if the application pool is recycled or the webserver is low on memory. You could try using StateServer mode, whereby sessions are stored in a separate service running on the server. You can change the mode in web.config eg.

<system.web>
    <sessionState mode="StateServer"/>
    </sessionState>
</system.web>

See http://support.microsoft.com/kb/307598

Dan Diplo