Why viewstate nearly killed me
I've been working for the last two months on a huge e-commerce site with a configurator of high-end gaming PCs. (http://www.hp.com/blackbird)
Because of complex rules of component interactions I was loading the entire component set (even though it is displayed on seperate pages) and relying on viewstate to keep track of what was selected. Because each selection could enable/disable any other as well as change messaging and force selection the logic to drive this was very complex. The initial decision of a base model also determined the base feature set to work with. All of the controls on the page would be dynamically created in the init function.
We started having sporadic invalid viewstate exceptions, with no consitent reproduction steps. I tried compressing the viewstate (which was large, at 16k), making sure I wasn't loosing the session (and therefore the model selection) and then moving the entire viewstate into session. Nothing seemed to work.
The problem seemingly came and went, several times we thought we had eliminated it but it would reappear.
The problem came down to how I was trying to optimize the data queries, and storing information in appdomain. I had inadvertently stored some information that was model dependant in the application domain and if multiple people were choosing different models at the same time the viewstate would be different than the created list of controls. Sometimes.
Anyway after a week and a half of monkeying with the viewstate it turned out that the exception message was right and the list of controls was mismatched.
I'll put up another post with some of the other solutions I tried as well.
Because of complex rules of component interactions I was loading the entire component set (even though it is displayed on seperate pages) and relying on viewstate to keep track of what was selected. Because each selection could enable/disable any other as well as change messaging and force selection the logic to drive this was very complex. The initial decision of a base model also determined the base feature set to work with. All of the controls on the page would be dynamically created in the init function.
We started having sporadic invalid viewstate exceptions, with no consitent reproduction steps. I tried compressing the viewstate (which was large, at 16k), making sure I wasn't loosing the session (and therefore the model selection) and then moving the entire viewstate into session. Nothing seemed to work.
The problem seemingly came and went, several times we thought we had eliminated it but it would reappear.
The problem came down to how I was trying to optimize the data queries, and storing information in appdomain. I had inadvertently stored some information that was model dependant in the application domain and if multiple people were choosing different models at the same time the viewstate would be different than the created list of controls. Sometimes.
Anyway after a week and a half of monkeying with the viewstate it turned out that the exception message was right and the list of controls was mismatched.
I'll put up another post with some of the other solutions I tried as well.
Labels: .net, controls, dymamic, exception, invalid, viewstate

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home