gpt4 book ai didi

asp.net - 当启用 EnabledEventValidation 时,Firefox 中出现无效 ViewState 错误

转载 作者:行者123 更新时间:2023-12-02 14:30:14 24 4
gpt4 key购买 nike

我有一个稳定的错误,每次点击F5时都会重现: Error

有 2 个网格(主从),并且错误实际上发生在主网格上发生聚焦行更改事件时由我的客户端代码引发的回调上。像这样的事情:

    this.mainGrid.ClientSideEvents.FocusedRowChanged = string.Format(@"
function(s, e)
{{
if (typeof({0}) != 'undefined')
{0}.PerformCallback(s.GetFocusedRowIndex());
}}",
this.detailsGrid.ClientInstanceName);

该错误仅在 mozilla firefox 中重现! (是的,IE 没有受到质疑,这有点奇怪=))

非常重要的事情:该错误仅在事件验证开启时才会重现,即:

... EnableEventValidation="false" %>   // no error in this case

我认为原因是回调在加载必要的字段之前被触发(据我所知,事件验证使用一些隐藏字段),所以我使用 setTimeout 检查了这一点:

this.mainGrid.ClientSideEvents.FocusedRowChanged = string.Format(@"
function(s, e)
{{
window.setTimeout(function () {{
if (typeof({0}) != 'undefined') {0}.PerformCallback(s.GetFocusedRowIndex());
}}, 2000);
}}",
this.detailsGrid.ClientInstanceName);

但这并没有帮助。 2 秒过去了,回调开始,我收到错误。它仅在刷新时发生 - 第一次加载页面时不会引发错误。禁用网格的行缓存也没有帮助。需要帮助! =))

编辑:这是 StackTrace

   at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded()
at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)
at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)
at System.Web.UI.WebControls.HiddenField.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.WebControls.HiddenField.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.solutions_cashcenter_stockmanagement_frames_takeintostorageordersviewframe_aspx.ProcessRequest(HttpContext context) in c:\Users\udod\AppData\Local\Temp\Temporary ASP.NET Files\website\b07be668\e534e3ef\App_Web_jeqyhxze.10.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Edit2: 'EnsureEventValidationFieldLoaded' - 是的,我明白这一点,但是...如果我等待 2 秒,它怎么可能无法加载???

Edit3:您可能会注意到这不是 IIS 问题(屏幕截图中的 127.0.0.1 IP)。

编辑:向上!!!

最佳答案

昨天我遇到了同样的错误,并在这里发现了类似的问题:http://sietch.net/ViewNewsItem.aspx?NewsItemID=185

我当前的解决方法是:

$(document).ready(function(){
$('#__EVENTVALIDATION').attr('autocomplete', 'off');
});

这似乎有效。但我仍在测试。

关于asp.net - 当启用 EnabledEventValidation 时,Firefox 中出现无效 ViewState 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12897288/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com