Why am I losing sessions when running in StateServer mode?
I have checked the servers (Win Server 2003) application event logs for the following problem http://support.microsoft.com/kb/308097 which doesn't show up. It just appears that sessions drop randomly for random users
It's a single server setup, no web farms and no load balancing
Even though the issue I point to above doesn't occur in the logs, is it worth increasing the stateNetworkTimeout attribute anyway? The configuration at the moment is simply
<sessionState mode="StateServer" cookieless="false" stateConnectionString="tcpip=localhost:42424" timeout="60"/>
UPDATES:
Using FormsAuth and开发者_StackOverflow the Timeout is set to 60
IIS6 Settings
- Recycle worker processes (in minutes) = 120
- Recycle worker processes (number of requests) = 35000
- Recycle worker processes at the following times = Unchecked
- Maximum virtual memory = Unchecked
- Maximum used memory = Unchecked
- Shutdown worker processes after being idle = 90
- Limit the kernel request queue = 1500
- Everthing else = Unchecked
I realize this is an older question, but I recently experienced a similar issue. In my case, additional logging revealed that Session variables were being lost seemingly at random across a series of .aspx pages.
After stumbling upon this blog post I reviewed my code and sure enough, all of my Response.Redirect statements were either the default (e.g. Response.Redirect(target), or true (e.g. Response.Redirect(target, true) ). After judiciously reviewing my redirects and setting the ones that came after the setting of Session variables to false (e.g. Response.Redirect(target, false) ) -- problem [seemingly] solved! I would note that you need to be careful when doing this as the rest of the page will still execute after the redirect when passing false. In many cases I needed to add a return statement just after the redirect to prevent running code that I didn't intend to run after the redirect.
I only experienced lost session variables in production, and under load (never in development or testing). My theory on why this solved my problem is that Response.Redirect (default/true) forcibly ends the executing thread -- if the thread is still busy working serializing the session objects and placing them back into the state server when it (the thread) is interrupted, they (the session objects) can be lost.
you also need to set the timeout in forms authentication section (30 min by default)
http://weblogs.asp.net/scottgu/archive/2005/11/08/430011.aspx
精彩评论