Failed to load viewstate - no dynamically loaded controls

466 views Asked by At

We are getting sporadic reports of the famous "Failed to load viewstate". It is very difficult to track down because we are not using any dynamically loaded controls. And it is sporadic.

"Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back"

What other reasons can there be for this? We have not logged any application pool recyclings.

1

There are 1 answers

2
n8wrl On BEST ANSWER

Several possibilities:

On the page, some control is being added or removed since the page was sent to the client.

On a web-farm, the page might be processed by a different server with a different 'machine code' for encryption. I don't recall the exact syntax but you can set it so they're all the same in web.config.

I have seen this if the page itself was edited on the server and then an 'old version' is posted-back. But it seems like you'd know if that happened.

And depending on how long the page was 'in the wild' server updates or even reboots between the time it was sent and posted-back could change the machine-code. Again, set it in web.config to prevent this.

Oh - one more - some browsers truncate form fields so if you have A LOT of viewstate it might be getting truncated by the browser on post-back. That would screw it up.