問題描述
我在這里幾乎沒有什么可做的.我無法在本地重現(xiàn)此內(nèi)容,但是當用戶收到錯誤消息時,我會收到自動電子郵件異常通知:
I have very little to go on here. I can't reproduce this locally, but when users get the error I get an automatic email exception notification:
Invalid length for a Base-64 char array.
at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
at System.Web.UI.HiddenFieldPageStatePersister.Load()
我傾向于認為分配給視圖狀態(tài)的數(shù)據(jù)存在問題.例如:
I'm inclined to think there is a problem with data that is being assigned to viewstate. For example:
List<int> SelectedActionIDList = GetSelectedActionIDList();
ViewState["_SelectedActionIDList"] = SelectedActionIDList;
如果不能在本地重現(xiàn)錯誤,就很難猜測錯誤的來源.
It's difficult to guess the source of the error without being able to reproduce the error locally.
如果有人遇到過這個錯誤,我真的很想知道你發(fā)現(xiàn)了什么.
If anyone has had any experience with this error, I would really like to know what you found out.
推薦答案
我已經(jīng)看到這個錯誤是由合適的視圖狀態(tài)和過度激進的內(nèi)容過濾設(shè)備/防火墻(尤其是在與 K-12 教育機構(gòu)打交道時)引起的).
I've seen this error caused by the combination of good sized viewstate and over aggressive content-filtering devices/firewalls (especially when dealing with K-12 Educational institutions).
我們通過在 SQL Server 中存儲 Viewstate 來解決這個問題.在走這條路之前,我建議嘗試限制您對視圖狀態(tài)的使用,不要在其中存儲任何大的東西,并為所有不需要它的控件關(guān)閉它.
We worked around it by storing Viewstate in SQL Server. Before going that route, I would recommend trying to limit your use of viewstate by not storing anything large in it and turning it off for all controls which do not need it.
在 SQL Server 中存儲 ViewState 的參考:
MSDN - PageStatePersister 概述
ASP 聯(lián)盟 - 在 SQL Server 中存儲視圖狀態(tài)的簡單方法
代碼項目 - ViewState 提供者模型
References for storing ViewState in SQL Server:
MSDN - Overview of PageStatePersister
ASP Alliance - Simple method to store viewstate in SQL Server
Code Project - ViewState Provider Model
這篇關(guān)于導(dǎo)致此“Base-64 字符數(shù)組的長度無效"的原因是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!