wpr*_*prl 10 asp.net viewstate validation exception
ASP.NET中此异常的原因是什么?显然它是一个视图状态异常,但我无法在抛出异常的页面上重现错误(带有按钮和导航链接的简单两个TextBox表单).
FWIW,我没有运营网络农场.
错误消息:无法验证数据.
错误来源:System.Web
错误目标站点:字节[] GetDecodedData(字节[],字节[],Int32,Int32,Int32 ByRef)
VIEWSTATE:
/ wEPDwULLTE4NTUyODcyMTFkZF96FHxDUAHIY3NOAMRJYZ + CKsnB
EVENTVALIDATION:
/ wEWBAK + 8ZzHAgKOhZRcApDF79ECAoLch4YMeQ2ayv/Gi76znHooiRyBFrWtwyg =
at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
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()
at System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
at System.Web.UI.Page.LoadAllState()
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.default_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Run Code Online (Sandbox Code Playgroud)
~William Riley-Land
Chr*_*tal 18
导致此错误的最可能原因是在所有视图状态加载(用户点击停止或返回按钮)之前停止回发时,视图状态将无法验证并抛出错误.
其他潜在原因:
更新:微软关于这个问题的文章.除上述内容外,他们还提出了另外两个可能的原因:
在.NET 3.5 SP1中,RenderAllHiddenFieldsAtTopOfForm属性已添加到PagesSection配置中.
Web.config文件
<configuration>
<system.web>
<pages renderAllHiddenFieldsAtTopOfForm="true"></pages>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
有趣的是,默认值为true.因此,实质上,如果您使用的是.NET 3.5 SP1,则ViewState会自动呈现在表单的顶部(在加载页面的其余部分之前),从而消除了您获得的ViewState错误.
我遇到了某些特定版本的Safari 3的问题.我的解决方案是将ViewState移动到表单的顶部(扩展Page类并覆盖3.5之前的Render方法,或.Net 3.5 SP1及更高版本默认情况下这样做),并将ViewState拆分为几个不同的字段而不是一个怪物文件.请参阅ASP.NET 2.0中的ViewState Chunking(maxPageStateFieldLength)
归档时间: |
|
查看次数: |
36154 次 |
最近记录: |