无法加载视图状态。控制树成视图状态正在加载 [英] Failed to load viewstate. The control tree into which viewstate is being loaded

查看:206
本文介绍了无法加载视图状态。控制树成视图状态正在加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个用户控件内承载一个ASP.NET表单上的HTTP POST之后收到以下错误消息:

I am receiving the following error message after an HTTP POST on an ASP.NET form hosted inside a UserControl:

无法加载视图状态。到被加载视图状态的控件树必须被用于在previous请求期间保存视图状态的控件树相匹配。例如,动态添加控制时,在一个后回加的控制必须初始请求时添加的控制的类型和位置相匹配。

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.

下面是另外的信息:

  • 在我运行.NET 4.5 RC
  • 这是一把umbraco 4.7为基础的网站
  • 在我的本地开发计算机的形式作品的完全
  • 在此错误仅发生在临时服务器具有.NET 4.5(只),MSSQL 2012例preSS上,IIS 7.5,Windows 7的(我知道,这不是一个真正的服务器还没有,有一天也许... )
  • 服务器不是Web农场的一部分(或花园,寿应该是irrevelant)
  • 在用户控件的确实的渲染控制动态
  • I'm running .NET 4.5 RC
  • It's an Umbraco 4.7-based website
  • On my local dev machine the form works perfectly
  • This error only occurs on the staging server which has .NET 4.5 (only), MSSQL 2012 Express, IIS 7.5, Windows 7 (I know, it's not a real server yet, one day maybe...)
  • The server is not part of a web farm (or garden, tho that should be irrevelant)
  • The user control does render controls dynamically

我已经应用了所有最新的服务包。 我已经江郎才尽了吧!我甚至重新启动它,还表演了richual在服务器涉及的歌曲和舞蹈特别没有用。

I have applied all the latest service packs. I have run out of ideas now! I have even restarted it and also performed a richual over the server involving a song and a special dance to no avail.

感谢您的任何帮助或想法!

Thanks for any assistance or ideas!

推荐答案

当你添加控件什么是重要的动态是哪些事件要添加他们。

What is important when you are adding controls dynamically is on which event you are adding them.

如果您添加负荷后发生的事件的控制,他们将是您发送给客户端的视图状态的一部分。

If you added controls on events that occur after load, they will be part of the viewstate you send to the client.

您必须在 LoadViewState 再次添加这些控件的调用。

You will have to add those controls again before LoadViewState is called.

如果您遇到地方,其中控制增加了决策本身存储在 ViewState的情况下或控件的值,那么甚至在<$记C $ C>的ViewState 被加载,这个数据是可以在 Request.Params

If you run into cases where the the decision of which controls to add is itself stored in the ViewState or the value of a control, then remember even before the ViewState is loaded, this data is available in Request.Params

参考的 asp.net页面生命周期

这篇关于无法加载视图状态。控制树成视图状态正在加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆