Question: I'm getting the following error in my ASP.net web page:

Invalid length for a Base-64 char array.

This happens when a user activates an ajax request before the previous request completes. How can I prevent this error from occurring?

edit: here's the stack trace. Because the error doesn't appear to be happening in my own code, I'm not sure what to do.

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()

Answer: 
You could try and prevent subsequent requests during the ajax request:

```
function OnRequestStart(sender, args) {
                if (args.EventTargetElement) {
                    var control = document.getElementById("<%= SomeButton.ClientID %>");
                    if (control != null) {
                        if (args.EventTargetElement.id == control .id) {
                            control .disabled = true;
                        }
                    }
                }
            }
            function OnResponseEnd(sender, args) {
                if (args.EventTargetElement) {
                    var control = document.getElementById("<%= SomeButton.ClientID %>");
                    if (control != null) {
                        if (args.EventTargetElement.id == control .id) {
                            control .disabled = false;
                        }
                    }
                }
            }

```
Base64 strings have a length that is a multiple of three. While I cannot tell where the invalid Base64 string comes from it seems obvious that some code is trying to decode an string that is either a corrupted Base64 string or not a Base64 string at all.