Solved

Invalid length for a Base-64 char array

Posted on 2006-06-30
5
605 Views
Last Modified: 2008-01-09
Hello,

I'm getting the following error back from a central error handling routine in the global.asax:

Exception Message: Invalid length for a Base-64 char array.
Exception Source: mscorlib
Exception StackTrace:    at System.Convert.FromBase64String(String s)
   at System.Web.UI.LosFormatter.Deserialize(String input)
   at System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
Exception TargetSite: Byte[] FromBase64String(System.String)

I've seen other postings for this exception, but none have been helpful. It seems to be related to viewstate, but in this case, the stack trace doesn't event tell me the source page, so I don't know where to begin troubleshooting this.
0
Comment
Question by:LloydMc
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17018751
how are you creating the base64string that is being passed in?
0
 

Author Comment

by:LloydMc
ID: 17043395
apresto,

The base64 string is created by an query string encryption(DES) routine. Some further research revealed that the DES encryption method places "+" characters in the encrypted data and these get parsed as empty strings when the string is decrypted. I changed the decryption method to replace any empty strings with "+", but we're still getting the errors.

What's so maddening is the stack trace isn't telling me what page or process the error occured in.
0
 
LVL 23

Expert Comment

by:apresto
ID: 17043422
if you base64string has + or " ", get rid of them, If you havent done already you can use .Replace to do this:

MyBase64String.Replace("+", "").Replace(" ", "")

0
 

Author Comment

by:LloydMc
ID: 17043665
apresto,

I am replacing any empty spaces in the decrypted string with "+" chars, but we're still seeing the error, although we can't reproduce it.
0
 
LVL 23

Accepted Solution

by:
apresto earned 250 total points
ID: 17043741
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question