开发者

Invalid length for a Base-64 char array

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 开发者_StackOverflow中文版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()


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜