4

I understand this error happens upon receiving a request with Viewstate truncated or modified (where it does not confirm to base64 encoding).

Different sources on the web point me to the following reasons why this error could occur with related to viewstate,

  1. Connection was interrupted while making the request
  2. Browser failed to send the complete request
  3. Client modifies the request before posting back to server

Among the possible reasons, the server will receive the said content length in header only in 3rd case.

Having said that,

  • why aren't the other cases classified as Bad request by IIS?
  • Why is this request even being handed over to ASP.NET if the content received does not match with content length in the request header?

Am I missing any basics here?? thanks.

//Update 1

Ok. here are more details from my analysis,

When the connection was interrupted or aborted by the client, ASP.NET throws an exception that is caught in the Application_Error of global.ascx.

Interestingly here again, we see the Request.ContentLength greater than Context.Request.TotalBytes.

To me this obviously means the request was fully received by server. This confirms that IIS is the right candidate to have handled this and not given the request to ASP.NET at all.

Is there any configuration in IIS to acheive this? Is there any other good reasons, why IIS is not doing this by default?

Check the Exception and Watch windows in this screen shot

humblelistener
  • 1,456
  • 12
  • 22
  • 2
    This is the first time I am not being answered on stackoverflow... all geeks on vacation??? seriously.. is there anything wrong in the question or the way I presented?? – humblelistener Nov 15 '11 at 13:57
  • How much data are you storing in ViewState? I've had IIS blow up when someone accidentally stored thousands of records in ViewState. But, you're talking about 10-20MB of data. ViewState is meant for maintaining small amounts of data across postback (an id, sort order), not cached data. – Joseph Yaduvanshi Nov 15 '11 at 16:05
  • @JimSchubert how did you arrive that I am storing 10-20 MB of data in viewstate? I checked it now and it is 1023 bytes. – humblelistener Nov 15 '11 at 16:11
  • in my situation, it was storing 10-20MB of data. Is your application in a web farm or behind a load balancer? If so, you will need to make sure your machine key is not set to autogenerate, otherwise the validation and decryption keys would be different between requests when the origin is a different server from the destination. – Joseph Yaduvanshi Nov 15 '11 at 16:25
  • The error is reproducible on my local development machine .. which is not load balanced.. just a standalone development machine – humblelistener Nov 15 '11 at 16:35
  • 1
    See the answer at http://stackoverflow.com/questions/858761/what-causing-this-invalid-length-for-a-base-64-char-array I think it might be relevant. – Concrete Gannet Aug 01 '12 at 06:53

0 Answers0