1

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Sten
  • 1,079
  • 11
  • 25
  • Are you using any non-standard / 3rd party controls that are not part of the core .NET framework? – Nikki9696 Apr 14 '11 at 18:21
  • Can you find which control is causing it? See disabling "just my code" debugging answer in http://stackoverflow.com/questions/580704/failed-to-load-viewstate-happening-only-occassionally-tough-to-recreate – Nikki9696 Apr 14 '11 at 19:39

1 Answers1

0

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.

n8wrl
  • 19,439
  • 4
  • 63
  • 103
  • Thanks for you reply. "Some control": Nope, it cannot be this, we have checked the code and have not found anything like it. "Web-farm": No web farm used here. "Edited, old version": No, afraid not. "In the wild": It is happening so frequently that this hardly can be the problem. – Sten Apr 14 '11 at 17:36
  • @Sten I understand this is a very old question, but have you found what the problem was? – Yuriy Galanter Feb 02 '14 at 16:05