2010-05-14 109 views
1

我在我的ASP.net网页中收到以下错误:Base-64字符数组长度无效

Base-64字符数组的长度无效。

这发生在用户在前一个请求完成之前激活ajax请求时发生。我怎样才能防止这种错误发生?

编辑:这里是堆栈跟踪。由于该错误似乎没有出现在我自己的代码中,我不知道该怎么做。

在System.Convert.FromBase64String(字符串或多个) 在System.Web.UI.ObjectStateFormatter.Deserialize(字符串inputString) 在System.Web.UI.Util.DeserializeWithAssert(IStateFormatter格式化器,字符串serializedState) 在系统.Web.UI.HiddenFieldPageStatePersister.Load()

回答

-2

Base64字符串的长度是三的倍数。虽然我不知道无效的Base64字符串来自哪里,但似乎很明显,某些代码试图解码一个字符串,该字符串可能是受损的Base64字符串,或者根本不是Base64字符串。

+0

这里的堆栈跟踪。由于该错误似乎没有出现在我自己的代码中,我不知道该怎么做。 在System.Convert.FromBase64String(字符串或多个) 在System.Web.UI.ObjectStateFormatter.Deserialize(字符串inputString) 在System.Web.UI.Util.DeserializeWithAssert(IStateFormatter格式化器,字符串serializedState) 在的System.Web .UI.HiddenFieldPageStatePersister.Load() – 2010-05-14 20:41:47

+0

看起来非常明显,您的应用程序在尝试解码视图状态时崩溃,因为该值不是有效的Base64字符串。所以你必须找出为什么视图状态不再有效。 – 2010-05-14 21:20:44

0

你可以尝试,并防止Ajax请求在随后的请求:

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; 
         } 
        } 
       } 
      } 
+0

我真的建议先试着寻找并修复一个bug,而不是隐藏它。 – 2010-05-14 17:52:01