ViewStateException Invalid ViewState

Rate It (1)

Last post 01-08-2007 8:56 AM by addamse. 2 replies.

Sort Posts:

  • ViewStateException Invalid ViewState

    12-29-2006, 2:27 PM
    • Member
      point Member
    • addamse
    • Member since 12-29-2006, 2:17 PM
    • Posts 2
    My ASP.NET 2.0 web application is generating the following errors several times a day:
    1) System.Web.HttpException: The client disconnected. ---> System.Web.UI.ViewStateException: Invalid viewstate.
    2) System.Web.HttpException: The state information is invalid for this page and might be corrupted. ---> System.Web.UI.ViewStateException: Invalid viewstate. 
    I cannot find any information on Viewstate Verfication and am not sure why this error is occuring.  Also I am not sure if the user actually receives an error or is allowed to continue through the website.  A wide variety of user-agents are receiving this message.  I have attempted disabling the enableViewStateMac in the web.config, but this did not eliminate the error.  The application environment is a Windows Server 2003 with IIS 6.0.  The application is not running in a web farm.  Any help is greatly appreciated.
    
    Thanks in advance.
  • Re: ViewStateException Invalid ViewState

    12-31-2006, 3:58 AM
    • All-Star
      46,022 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    You probably have seen this one: http://west-wind.com/weblog/posts/2588.aspx (see the link to MS support KB on it) however with ASP.NET 2.0 sometimes it hashelped when one sets the max length of single viewstate field in web.config to smaller. For example

    <pages maxPageStateFieldLength="8192" />

    where 8192 is maximum number of characters for the state field. If entire state size is larger than this, state is separated into chunks where each chunk is less than 8192 characters. E.g it spans it to multiple viewstate fields. Default is -1 when no spanning happens.

     

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: ViewStateException Invalid ViewState

    01-08-2007, 8:56 AM
    • Member
      point Member
    • addamse
    • Member since 12-29-2006, 2:17 PM
    • Posts 2

    Thanks for your response joteke.  It gave me idea with the viewstate size suggestion you posted.  I think I found the cause of the issue.  It turns out that two the web controls (literals) that had viewstate enabled were receiving massive amounts of data for a particular case on the website (hence this was causing a very large viewstate).  I decided to disable the viewstate and hit the database to retrieve the data each load of the page from the db rather than store this data in the viewstate.  This appears to have reduced the issue greatly. 

Page 1 of 1 (3 items)