– Pesky “Invalid character in a Base-64 string.” Exception – Education Career Blog

Recently my application has been getting tons of these exceptions.

I run 3.5 on a Windows XP machine. The exceptions tend to be random.

The application uses the Telerik RadControls for ASP.NET AJAX Q2 2010 SP1.

The exception and StackTrace are below.

Exception Type: System.FormatException
Message: Invalid character in a Base-64 string.
StackTrace:  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.SessionPageStatePersister.Load()

Any ideas on what could be causing this? Also, this may or may not be related, often times pages with a decent amount of data (greater than 2 minutes load time) time out randomly. I’ve increased the timeout for each of these long-loading pages in web.config…

<location path="mypage.aspx">
  <httpRuntime executionTimeout="1920"/>

Thanks for any help.



See if your application pool/website is restarting for some reason (e.g. memory or time limit).

If the ViewState is not deserializing properly, the problem is either that ASP.NET cannot decrypt it properly, or something changed the value of the ViewState client field on the page. You can try disabling encryption in the web.config:

 <pages viewStateEncryptionMode=”Never”>

For the second reason, perhaps a firewall or other part of your project is modifying the ViewState. Check if you are using any optimization code on it and try disabling it.

Finally, you can try disabling ViewState for some controls that don’t need it to reduce its size or you can try using the maxPageStateFieldLength property in the web.config to split the input into several smaller ones.

Leave a Comment