解决:IE 10似乎在处理空字符时遇到问题。因为我们正在生成大量代码服务器端,所以缓冲导致List Item数据中出现NULL字符,最终破坏了ViewState(NULL不是有效的base64字符)。我注意到了这一点,因为小数据集上没有发生损坏
我通过在生成列表项时设置Response.Buffer = false
来解决此问题。我涉足的其他可能的解决方案:
- ListBox.DataSource = new DataView(dataTable)
和ListBox.DataBind()
。这导致了干净的数据,但在我的情况下需要更改存储过程
- 正常清除缓冲区,使NULL显示在<option>
元素之外
经过大量的研究后,我仍然在Web应用程序中遇到无效的viewstate错误。
总结:
EnableViewState="False"
,因此有关此方法的解决方法不是理想选项。NUL
个字符。 我的猜测是,在NUL字符处截断了ViewState,并且抛出了错误,因为预期的ViewState与接收的内容不同。但是,我坚持如何验证这一点,缩小导致损坏数据的原因,以及如何解决问题。
[NUL]
是一个合法的空字符查看状态:
...pZmUFBTE[NUL]4NjoxZxAFD1RJQUEt...
列表框中的一个选项:
<option value="201:1" title="Pr[NUL]emier 20">Premier 20</option>
代码
if (!IsPostBack)
{
System.Web.UI.WebControls.ListItem liListItem;
clsGLOBALGASubscription clsGAS = new clsGLOBALGASubscription(lngSubID);
DataTable dataTable = clsGAS.ListSelectedProducts(Session["GAID"].ToString().Trim());
if(dataTable == null)
{
lstbAvailable.Items.Add("There are no products available for your account. Please contact your administrator.");
btnAdd.Visible = false;
btnAddAll.Visible = false;
btnRemove.Visible = false;
btnRemoveAll.Visible = false;
}
else
{
if(Session["SelectedProducts"] != null && Session["SelectedProducts"].ToString().Trim().Length != 0)
{
foreach(DataRow dataRow in dataTable.Rows)
{
string strConcatIDs = dataRow["CompanyID"] + ":" + dataRow["SeriesID"];
liListItem = new ListItem(dataRow["Company"] + " - " + dataRow["Series"], strConcatIDs);
liListItem.Attributes.Add("title", String.Format("{0} - {1}", dataRow["Company"], dataRow["Series"]));
foreach(string subString in Session["SelectedProducts"].ToString().Split(delimiters))
{
if(subString == strConcatIDs)
if (xraeList)
{
foreach (string CarrierHealthItem in XraeCarrierList)
{
string[] CarrierInforArray = CarrierHealthItem.Split(':');
if (CarrierInforArray[0].ToString() == dataRow["CompanyID"].ToString())
{
foundXrae = true;
break;
}
}
if (foundXrae)
{
liListItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.Color, "Red");
liListItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight, "bold");
foundXrae = false;
}
}
lstbSelected.Items.Add(liListItem);
bSelectedAlready = true;
break;
}
}
if (bSelectedAlready == false)
{
if (xraeList)
{
foreach (string CarrierHealthItem in XraeCarrierList)
{
string[] CarrierInforArray = CarrierHealthItem.Split(':');
if (CarrierInforArray[0].ToString() == dataRow["CompanyID"].ToString())
{
foundXrae = true;
break;
}
}
if (foundXrae)
{
liListItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.Color, "Red");
liListItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight, "bold");
foundXrae = false;
}
}
lstbAvailable.Items.Add(liListItem);
}
else
{
bSelectedAlready = false;
}
}
}
else // ...no Selected Products, so just populate lstbAvailable
{
foreach(DataRow dataRow in dataTable.Rows)
{
liListItem = new System.Web.UI.WebControls.ListItem(dataRow["Company"] + " - " + dataRow["Series"], dataRow["CompanyID"] + ":" + dataRow["SeriesID"]);
liListItem.Attributes.Add("title", String.Format("{0} - {1}", dataRow["Company"], dataRow["Series"]));
if (xraeList)
{
foreach (string CarrierHealthItem in XraeCarrierList)
{
string[] CarrierInforArray = CarrierHealthItem.Split(':');
if (CarrierInforArray[0].ToString() == dataRow["CompanyID"].ToString())
{
foundXrae = true;
break;
}
}
if (foundXrae)
{
liListItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.Color, "Red");
liListItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight, "bold");
foundXrae = false;
}
}
lstbAvailable.Items.Add(liListItem);
}
}
}
}
}
错误:
The state information is invalid for this page and might be corrupted.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. ]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +90
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +60
System.Web.UI.HiddenFieldPageStatePersister.Load() +173
[ViewStateException: Invalid viewstate.
Client IP: 10.128.3.10
Port: 44359
Referer: http://LTCarrierProduct.aspx?Title=Customize Carriers and Products&XraeValidation=Invalid
Path: /LTCarrierProduct.aspx
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
ViewState: /wEPDwUJNzE5MTU3Njg2D2QWBgIBDxYCHgRUZXh0BY4BPExJTksgaHJlZj0nU3R5bGVzL0xUU3R5bGVzLmNzcycgdHlwZT0ndGV4dC9jc3MnIHJlbD0nc3R5bGVzaGVldCcgLz48TElOSyBocmVmPSdTdHlsZXMvMDE1ODFfTFRTdHlsZXMuY3NzJyB0eXBlPSd0ZXh0L2NzcycgcmVsPSdzdHlsZXNoZWV0JyAvPmQCAw8WAh8AZWQCBQ9kFgQCAQ8QZA8WxgFmAgECAgIDAgQCBQIGAgcCCAIJAgoCCwIMAg0CDgIPAhACEQISAhMCFAIVAhYCFwIYAhkCGgIbAhwCHQIeAh8CIAIhAiICIwIkAiUCJgInAigCKQIqAisCLAItAi4CLwIwAjECMgIzAjQCNQI2AjcCOAI5AjoCOwI8Aj0CPgI/AkACQQJCAkMCRAJFAkYCRwJIAkkCSgJLAkwCTQJOAk8CUAJRAlICUwJUAlUCVgJXAlgCWQJaAlsCXAJdAl4CXwJgAmECYgJjAmQCZQJmAmcCaAJpAmoCawJsAm0CbgJvAnACcQJyAnMCdAJ1AnYCdwJ4AnkCegJ7AnwCfQJ+An8CgAECgQECggECgwEChAEChQEChgEChwECiAECiQECigECiwECjAECjQECjgECjwECkAECkQECkgECkwEClAEClQEClgEClwECmAECmQECmgECmwECnAECnQE...]
[HttpException (0x80004005): The state information is invalid for this page and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +177
System.Web.UI.HiddenFieldPageStatePersister.Load() +11367569
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +11447671
System.Web.UI.Page.LoadAllState() +56
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11441698
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11441214
System.Web.UI.Page.ProcessRequest() +269
System.Web.UI.Page.ProcessRequest(HttpContext context) +167
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +625
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270
来自服务器上的ie.browsers:
<browser id="IE6to9" parentID="IE5to9">
<identification>
<capability name="majorversion" match="[6-9]" />
</identification>
<capture></capture>
<capabilities>
<capability name="jscriptversion" value="5.6" />
<capability name="ExchangeOmaSupported" value="true" />
</capabilities>
</browser>
答案 0 :(得分:0)
不确定这是否会有所帮助,但这是我们ie.browser
中的其他部分:
<browser id="IE5to9" parentID="IE">
<identification>
<capability name="majorversion" match="^[5-9]|[1-9]\d+" />
</identification>
<capture>
</capture>
<capabilities>
<capability name="activexcontrols" value="true" />
<capability name="backgroundsounds" value="true" />
<capability name="cookies" value="true" />
<capability name="css1" value="true" />
<capability name="css2" value="true" />
<capability name="ecmascriptversion" value="1.2" />
<capability name="frames" value="true" />
<capability name="javaapplets" value="true" />
<capability name="javascript" value="true" />
<capability name="jscriptversion" value="5.0" />
<capability name="msdomversion" value="${majorversion}${minorversion}" />
<capability name="supportsCallback" value="true" />
<capability name="supportsFileUpload" value="true" />
<capability name="supportsMultilineTextBoxDisplay" value="true" />
<capability name="supportsMaintainScrollPositionOnPostback" value="true" />
<capability name="supportsVCard" value="true" />
<capability name="supportsXmlHttp" value="true" />
<capability name="tables" value="true" />
<capability name="tagwriter" value="System.Web.UI.HtmlTextWriter" />
<capability name="vbscript" value="true" />
<capability name="w3cdomversion" value="1.0" />
<capability name="xml" value="true" />
</capabilities>
</browser>
为我们解决了很多问题。试一试。