同步回发后无效的ViewState

时间:2011-09-20 14:17:25

标签: asp.net asp.net-ajax updatepanel viewstate jquery-tabs

我遇到了UpdatePanel的问题。当用户单击面板内的按钮时,我会得到一个异步PostBack,并重新初始化一组jQuery选项卡。如果(在成功的第一次异步回发之后)我尝试使用UpdatePanel外的按钮或其他控件,我收到以下错误:

An error has occured on page: http://server/details.aspx for user:  at IP: 192.168.0.92
The state information is invalid for this page and might be corrupted.    at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
   at System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner, String persistedState)
   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.details_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) Invalid viewstate. 
    Client IP: 192.168.0.92
    Port: 1707
    Referer: http://server/details.aspx
    Path: /server/details.aspx
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322)
    ViewState: /wEPDwULLTEwMTkxMjEwNTNkZBSW/poBumnzl2Hp6YECMfZitwnKh80rC7JEaLc28HAh,z02m+uZDqc2t7iURUsMo+CuP5x4r/SPERT297Zo+E1XXWjvhDLPLpwJMqHic8o0GS89zNWWT5HUTr8DkPJgRKqGADUP0cXLYZ+seXS2JdxB85T6LsnrZwgBZC8hKDZPFlQtPIc9U0d5WCRQJFXRIHr3YLlQmTdXqcZBd09TrgA3y+hxpMJ4pq4kFU7wA9sZ0P+YFOzCNtIadsoXxZGzz+PjePHLPu+mwBAgLdI4mXYtA5MdgrH6OaM3eZaS9dZC5vpHWdC3b+ni3SkytO1FLhR4IUCNKIh+ApVtVNbfMkYAAAiXqSJKitUpZrqb3VM/EGsoZAK63iVAIpIBWkT/TeNU49UfofDChcMdsL/MLX2LEAMPG1BLhmcxIVPWJzGdCldPk5FDie6m2Wm5SRah3oMpcltVUv0wjGOo04TLOmrb/vw5iXyXAPC0eHch60Bm2gGCxY/PKTa9A/mWIyXwnVT2Ma0mi6i9gkvsDyWVN/u/ckNQrM4yN31y1vFwXG3jP+2euwDcZ41eK4md7FM6tBFZOvR7RV2mSI4BvJliLihfcje9IEEv9/X1zuz73RZrEYKVuCN/gFJNwRDJgYia2sCo1oE3NQn5guMFk+YSg9xzMgEQ0SmejhqnfughBrnbzhFWNXbCHz/hTkeBFYRRx/k3uTDpffW4qsVTL+VyZr3b8QKLZELNCrx2wqVSpup0/Mux65WDJykvcMbOq+... 
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.     at System.Convert.FromBase64String(String s)
   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()

我不确定如何对此进行故障排除,不同标签上的updatepanel内的所有其他内容似乎都有效。

2 个答案:

答案 0 :(得分:1)

可能会因为几个原因而发生。

最重要的是,刷新时的Ajax控件正在创建自己的viewstate,它取代了主页面viewstate。

我在其他论坛上阅读了一些解决方案,例如添加

             Response.End

在Ajax输出之后。使用Response.End

时,可能需要处理ThreadAbortException

另一个用户的第二种建议方式是从Ajax表单元素中取消Runat。

当Ajax回发网址转到单独的页面来获取数据时,也会发生这种情况。如果是这种情况,您可能希望将URL更改为同一页面。

答案 1 :(得分:0)

也许你动态创建新的控件,它有一个具有viewstate的形式,这就是为什么......?