2
Error Message: Invalid length for a Base-64 char array.
Stack Trace:
at System.Convert.FromBase64String(String s) 
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) 
at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) 
at System.Web.UI.HiddenFieldPageStatePersister.Load()

This is being thrown on every page view, regardless of page. I can't replicate on my dev server, and nowhere in my code have I used Base-64 (certainly nowhere that's called on every page view).

Any ideas?

Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
  • You can see from the stack trace that this has to do with page state persistence. That's who's using Base 64. – John Saunders Jan 20 '12 at 01:10
  • Have you checked the size/state of your viewstate (it sounds like you're using web forms)? http://stackoverflow.com/questions/858761/what-causing-this-invalid-length-for-a-base-64-char-array popped up. – Khepri Jan 20 '12 at 01:11
  • It's related to the ViewState. The ViewState is a base-64 encoded hidden input. The framework will read this value (and decode it; where you are blowing up) on every postpack. Are you load balanced? – vcsjones Jan 20 '12 at 01:11
  • @vscjones I fear I'm out my depth here, we're just on one server. I feel when I started the site I didn't have a good understanding of viewstates which is reflected when I view the source of my pages, some of them have huge viewstates. It doesn't seem to break my browsing experience, is this breaking the browsing experience for visitors or is it a hidden error to them? – Tom Gullen Jan 20 '12 at 01:13
  • 3
    Is your environment that's crashing a load-balanced environment? – David Hoerster Jan 20 '12 at 01:39
  • are you using web-forms or MVC3? – Sleiman Jneidi Jan 20 '12 at 01:41
  • Web-forms, and @David I don't really understand what that question means sorry :S I've been having problems recently where the apppool crashes (that's what our webhost said) and it throws HTTP503's until I reboot the server – Tom Gullen Jan 20 '12 at 01:58
  • ASP.NET 2.0? 4.0? Are you using any third party controls (Telerik, Infragistics etc)? – Kev Jan 20 '12 at 02:31
  • @Kev ASP.net 4.0 and no 3rd party controls. We are running a Classic ASP forum in the same AppPool though. – Tom Gullen Jan 20 '12 at 03:16
  • How big is your `__VIEWSTATE` hidden field on these pages, can you copy to a pastebin or copy and paste to an editor and see how many chrs? – Kev Jan 20 '12 at 03:35
  • check here http://weblogs.asp.net/owscott/archive/2004/11/02/What-causes-ViewState-Errors.aspx – Developer Jan 20 '12 at 08:01
  • @Kev I'm not sure if pasting my viewstate would be a security issue, the site is http://www.scirra.com, the forum is classic ASP the rest of the site is .net. If you go to http://www.scirra.com/blog pages like that seem to have big viewstates – Tom Gullen Jan 20 '12 at 10:25
  • @User thanks for link, but I think none of those points apply to this case unfortunately – Tom Gullen Jan 20 '12 at 11:28
  • @Kev FYI, the page Tom linked has a `__VIEWSTATE` with a "value" attribute that has 12,229 characters in it. I'm not experienced enough to know whether or not that is large (it sounds large). – Josh Darnell Jan 20 '12 at 14:58
  • 1
    @jadarnel27 - that doesn't sound hellishly bad, I've seen viewstate's a magnitude larger than that before. I suspect the problem here is that the viewstate is being truncated. Tom, if the problem is happening on public facing pages can you paste to a pastebin the viewstate of a page that does actually fail (I can't seem to repro on your site)? Don't worry about security because the value is effectively public anyway. – Kev Jan 20 '12 at 16:25

1 Answers1

0

Please see the following similar but solved threads for further details: What causing this "Invalid length for a Base-64 char array" http://forums.asp.net/t/1222829.aspx/1

I hope this might help.

Community
  • 1
  • 1
Shahzad Latif
  • 1,408
  • 12
  • 29