gpt4 book ai didi

asp.net - 如何修复此页面的状态信息无效并且可能已损坏

转载 作者:行者123 更新时间:2023-12-04 21:25:44 24 4
gpt4 key购买 nike

我正在开发一个 Asp.net 项目,在该项目中,我通过页面对象上的 LoadControl() 在页面上动态创建了一些用户控件,但是当我尝试通过任何页面进行任何回发时,我得到 "The state information is invalid for this page and might be corrupted."即使我已将动态创建的控件的 Viewstate 设置为 false。

如果您遇到过这个问题,请告诉我您是如何解决的。

堆栈跟踪是:-

[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) +77
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +147

[ViewStateException: Invalid viewstate.

[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) +198
System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState) +14
System.Web.UI.HiddenFieldPageStatePersister.Load() +251
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
System.Web.UI.Page.ProcessRequest() +78
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.contact_us_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\otherland_ecom\33f31476\6c5f9007\App_Web_zgmfrrfa.14.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

最佳答案

请确保在 Page_Load 之前加载了动态控件。您可以在 Page_Init 中加载它们。 (无需分配值,因为它们将从 View 状态分配)。

关于asp.net - 如何修复此页面的状态信息无效并且可能已损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3476124/

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