0

I have an error in an web application writen in asp.net 4.0 with c#. There is a viewstate or viewstate-MAC error with the following message:

[FormatException: The Input is not a valid Base-64-String....]
.
.
[ViewStateException: Invalid ViewState....]

I´ve tried everything I found on the web for this error.The error appears if the user clicks on an icon redirecting to the details patch of the selected item of an ListView.

Tried without success:

I hope anyone can help me with this frustrating error. Thx in advance to all of u...

Community
  • 1
  • 1
index
  • 1
  • 1
  • Is this application running on a web farm? I don't know if it will help, but you could try setting enableViewStateMac to false in the web.config. – James Johnson Aug 17 '11 at 15:13
  • How large is the viewstate for that page? – James Johnson Aug 17 '11 at 15:23
  • The application is NOT running on a webfarm, setting a machine key does not solve the problem. – index Aug 17 '11 at 15:37
  • The viewstate is allowed to be as big as he wants to be, but where can I see his real size? I have the following setting in my web.config: – index Aug 17 '11 at 15:40
  • the ViewState- Size is about 200KB. – index Aug 17 '11 at 21:23
  • That's WAY too big! 200 KB!? That will definitely create problems... – James Johnson Aug 17 '11 at 21:31
  • The related page is an ListView with more than 1000 entrys. How I can change the size of the viewstate when the related page has so much content? – index Aug 18 '11 at 23:35
  • You shouldn't be rendering 1000 entries to the page anyways, as this will kill performance. You should implement paging, and set the page size to something like 100 to start, with the ability to go up to 200-300 per page. Even with 1000 entries though, the ViewState shouldn't be anywhere near 200 KB. There's something very wrong if it's that size. My most data intensive pages have a ViewState no larger than 20-30 KB. Yours is 10x that size... – James Johnson Aug 18 '11 at 23:43
  • I actually just thought of a good test to check whether the size of the ViewState is causing this error. At the database level, temporarily limit the row count to 20 and see if it still breaks. If it doesn't break, then you know what the problem is. If it does break, then it's something else. Either way though, you need to figure out a way to reduce the size of the ViewState. – James Johnson Aug 18 '11 at 23:46

1 Answers1

0

Since your application is not distributed, try adding this to your web.config:

<pages enableViewStateMac="false">
James Johnson
  • 45,496
  • 8
  • 73
  • 110