getting error in webpage

Posted by Abhi_patil under ASP.NET on 5/7/2009 | Views : 1497 | Status : [Member] | Replies : 4
hi i am getting error in my web application as
''Invalid length for a Base-64 char array.''

i don't know why this is comming.
but application is working fine..

here it is stack strace:
Stack Trace: at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
at System.Web.UI.HiddenFieldPageStatePersister.Load()

plz suggest me answer.
thanks.




Responses

Posted by: Vuyiswamb on: 5/7/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Morning

Are you doing some encryption work ? See how other people solved the problem. i cant tell you because i dont see your code

http://social.msdn.microsoft.com/forums/en-US/csharplanguage/thread/4f38f84a-9bb0-41ba-8f81-4e3b83566194/


http://kiranpatils.wordpress.com/2008/03/13/invalid-length-for-a-base-64-char-arrayrijandelmanagedencryption/


http://dev.communityserver.com/forums/p/485297/570797.aspx

http://blogs.msdn.com/carloc/archive/2008/11/05/invalid-length-for-a-base-64-char-array.aspx

http://66.129.67.4/t/1251859.aspx


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi_patil on: 5/7/2009 [Member] Starter

Up
0
Down
i have searched all these articles but i couldnot get answer.
also i have set

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


Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nareshgoradara on: 5/9/2009 [Member] Starter

Up
0
Down
Can you please give some code from where it comes?


Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tridev_2005 on: 10/23/2009 [Member] Starter

Up
0
Down
This problem is more than likely related to the replacement or removal of characters from the crypt string which has been passed back from Protx. For example, the equals signs in the Base64 string. The problem is related to the way in which Base64 encoding works.

Base64 encoding takes three bytes, each consisting of 8 bits, and represents them as four ASCII characters. Therefore if the size of the original data in bytes is a multiple of three, everything works fine. If it is not, we might end up with one or two 8-bit bytes. However, for proper encoding, we need exactly three bytes. The solution is to append enough bytes with a value of '0' to create a 3-byte group. These trailing '0's must be represented by a 65th character which is an '='.

So, if these equals signs are being stripped or replaced then the string becomes an invalid length, hence the error message.

The same also applies to the + symbols in the string which might have been removed or have been replaced with spaces (treated as URL encoding). The plus symbols must remain to decode the string.

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response