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.
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 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.
addamse
0 Points
2 Posts
ViewStateException Invalid ViewState
Dec 29, 2006 06:27 PM|LINK
joteke
All-Star
46224 Points
6896 Posts
ASPInsiders
MVP
Re: ViewStateException Invalid ViewState
Dec 31, 2006 07:58 AM|LINK
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.
Teemu Keiski
Finland, EU
addamse
0 Points
2 Posts
Re: ViewStateException Invalid ViewState
Jan 08, 2007 12:56 PM|LINK
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.