Blog Stats
  • Posts - 170
  • Articles - 4
  • Comments - 54
  • Trackbacks - 7

 

Viewstate error

After a series of tests, I noticed that if you let a PC with an ASP.Net page opened, just come back the day after and refesh the page, you can randomly get this error:

System.Web.HttpException: 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 must match the type and position of the controls added during the initial request

Anybody has an idea what could have caused the problem here ?

I already use EnableViewstateMac="false" in the page declaration.

 


Feedback

# re: Viewstate error

Gravatar The only thing I can think of is that ASP.NET applications are unloaded from memory after a time of inactivity. That's why there's the delay/pause when you visit an ASP.NET application first or after some time - certain parts are compiled at runtime and then loaded into memory.

So. If you had an aspx page with many server controls, that would cause a very large viewstate, and if the application were unloaded from memory, depending on what controls are being used, they might be referencing an inexistant object. That's just a guess though.

Have you tried simply the EnableViewstate=False Page Directive, as opposed to EnableViewstateMac? 12/7/2004 2:04 PM | Jamie Plenderleith

# re: Viewstate error

Gravatar Hi Jamie
Yes I tried but the problem is that I need some Viewstate on most of the controls. All the content is database driven,so if I remove the viewstate, I will have to repopulate every box each time I load the page. Not sure it's the right thing to do regards of performance 12/7/2004 2:53 PM | Paschal

# re: Viewstate error

Gravatar My guess is that the web page's control tree structure must have changed between page calls. The ViewState is a server stateless mechanism so should not be affected by any time period between page loads, unless the application was changed or the control tree is populated dynamically. 12/7/2004 2:59 PM | Gavin Joyce

Comments have been closed on this topic.
 

 

Copyright © Paschal L