加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 03:19:41 所属栏目:asp.Net 来源:网络整理
导读:我正在开发一个 Asp.net项目,我通过页面对象上的LoadControl()动态地在页面上创建了一些用户控件,但是当我尝试通过任何页面进行任何回发时,我得到“状态信息对于此页面无效可能已经腐败了.“即使我已将动态创建的控件的Viewstate设置为false. 如果您遇到此问
我正在开发一个 Asp.net项目,我通过页面对象上的LoadControl()动态地在页面上创建了一些用户控件,但是当我尝试通过任何页面进行任何回发时,我得到“状态信息对于此页面无效可能已经腐败了.“即使我已将动态创建的控件的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:WindowsMicrosoft.NETFrameworkv4.0.30319Temporary ASP.NET Filesotherland_ecom33f314766c5f9007App_Web_zgmfrrfa.14.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +75

解决方法

在设计页面(.aspx)中将EnableEventValidation设置为false

<%@ Page Title="Home Page" EnableEventValidation="false" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读