2010-05-14 86 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

相關問題