'System.Web.HttpException:无法加载viewstate

时间:2011-06-17 18:26:12

标签: c# asp.net viewstate

我有一个usercontrol,其中包含文本框,下拉列表控件,复选框,gridview,超链接。页面加载时会显示一些控件 根据用户从下拉列表控件和复选框中的选择,其余部分可见。

此页面的功能与用户使用上述控件输入到文件中的数据相同,并在gridview中显示此文件 用户信息,如他的姓名,创建日期,服务类型,联系信息,服务时间和评论以及上述创建的文件。

该页面适用于我而没有任何错误,但是用户正在收到'System.Web.HttpException:无法加载viewstate。'偶尔会出错。

如何重现此错误?我该如何解决?

以下是整个错误消息:

Exception of type 'System.Web.HttpUnhandledException' was thrown.   
    System.Web.HttpException: Failed to load viewstate.  
    The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  
    For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState)
   at System.Web.UI.Control.LoadViewStateRecursive(Object savedState)
   at System.Web.UI.Page.LoadAllState()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)       
   at System.Web.UI.Page.HandleError(Exception e)
   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.app_uatserviceoutcome_aspx.ProcessRequest(HttpContext context) 
   in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\bad754dd\a11f74ff\App_Web_uatserviceoutcome.aspx.ae7ca9bd.xvr6rpyt.0.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

这是一个经典的webforms陷阱,很难追查 - 请参阅this question了解一些建议