是什么导致了“Base-64 字符数组的长度无效"? [英] What causing this "Invalid length for a Base-64 char array"
问题描述
我在这里没什么可做的.我无法在本地重现此内容,但是当用户收到错误消息时,我会收到自动电子邮件异常通知:
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()
我倾向于认为分配给视图状态的数据存在问题.例如:
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;
如果不能在本地重现错误,就很难猜测错误的来源.
It's difficult to guess the source of the error without being able to reproduce the error locally.
如果有人对此错误有任何经验,我真的很想知道您发现了什么.
If anyone has had any experience with this error, I would really like to know what you found out.
推荐答案
我见过这个错误是由大尺寸的视图状态和过于激进的内容过滤设备/防火墙(尤其是在与 K-12 教育机构打交道时)).
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 解决了这个问题.在走这条路线之前,我建议您尝试通过不要在其中存储任何大型内容并为所有不需要它的控件关闭它来限制您对 viewstate 的使用.
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 Alliance - 在 SQL Server 中存储视图状态的简单方法
代码项目 - 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
这篇关于是什么导致了“Base-64 字符数组的长度无效"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!