0

How to prevent this error in aspx page in c# ?

Message: Invalid length for a Base-64 char array.

On this code behind line :

byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);

In Google search I have find this:

The problem seems to be with the ViewState.

The ViewState is encrypted, and when an attempt is made to decrypt it on postback, the error is triggered.

I have tried this solution in the web.config file, on set ViewState not to be encrypted without success, like this:

<system.web>
<pages viewStateEncryptionMode=”Never”>
</pages>
</system.web>

Please help me, thank you so much in advance.

Antonio Mailtraq
  • 1,397
  • 5
  • 34
  • 82
  • read this one: http://stackoverflow.com/questions/1821243/cryptographicexception-padding-is-invalid-and-cannot-be-removed-and-validation/2551810#2551810 – Aristos Nov 13 '15 at 08:28
  • if the viewstate is too large, maybe its cuts out on post back, maybe you need to split it or compress it, or both... find out why is corrupted as first step. – Aristos Nov 13 '15 at 08:30

0 Answers0