开发者

Dynamically adding controls to ASP.NET - viewstate is not retained after 20 minutes

开发者 https://www.devze.com 2023-01-28 01:03 出处:网络
We have a ASP.net form [.NET 3.5 on IIS 6] that loads controls dynamically.We are able to retain the values in the viewstate as long as the postback happens within 20 minutes.The database also gets up

We have a ASP.net form [.NET 3.5 on IIS 6] that loads controls dynamically. We are able to retain the values in the viewstate as long as the postback happens within 20 minutes. The database also gets updated properly. Everything wo开发者_如何学运维rks as expected.

However, If it takes more than 20 minutes for a user to fill out the form, the controls no longer retain their values during postbacks. The session values are intact, the user authentication is also intact. We tried several things

1) Added machine keys to web.config files - we have 2 web servers load balanced by Windows load balancer

2) We confirmed that the user are routed to the same server – because the sessions are sticky

3) Increased the session timeout to 60 minutes in IIS 6.0

4) Increased the Idle timeout for connection pool to 60 minutes

5) Changed Form authentication ticket timeout to 60 minutes

Any help would be appreciated.

-Thanks


20 minutes is the default timeout for application pool recycling. Run IIS Manager on the server, go into the Application Pool properties, and unclick 'Recycle worker processes (in minutes)', or set it to 60.


"sticky" sessions do not mean "always go to same server". It is just a suggestion. Granted, a strong one, but still just a suggestion. The load balancer works by keeping an in memory cache of clients and their destination server. This memory is limited and is garbage collected on a regular basis. Meaning, you might very well be bouncing between servers based on the amount of time between requests.

If you are using in memory session data with load balanced machines, then you have to either 1. stop using session or change the backing store to be a session state server or sql server. This is the only way to be sure that the session data is actually available across all target servers.

How did you determine that the session and user values were still intact? Are you just guessing like you are about which server they are going to?

To completely eliminate load balancing as a culprit, turn off all but one of the machines.


Problem can be in <sessionPageState historySize="9" /> configuration. It control's how many "postback results" are stored in Session. Each postback records it's ViewState to the end of the Queue in Session["__VIEWSTATEQUEUE"].

0

精彩评论

暂无评论...
验证码 换一张
取 消