使用动态数据时,为什么我的视图状态在回发之间不断增长?
我正在使用 ASP.NET 动态数据编写一个非常复杂的 Web 表单。 由于控件之间存在依赖关系,因此该表单上的几个控件会回发。 我注意到视图状态随着每次回发而变得越来越大,直到大约 5 年后,渲染过程和 Web 浏览器中实际加载的页面之间存在很长的延迟。
即使我只是单击单选按钮来引起回发,而不在表单中输入任何数据或任何其他更改,也会发生这种情况...
我检查了旧版本的表单,它不使用动态数据和视图状态根本不增长...所以我推测动态数据控件在某种程度上应该受到指责...
其他人看到过这个吗? 有解决办法吗?
I'm writing a pretty complex web form using ASP.NET Dynamic Data. Several of the controls on this form post back, since there are dependencies between controls. I'm noticing that the viewstate is growing larger with every postback, until after 5 or so there is a long delay between the Render process and the page actually loading in the web browser.
This occurs even if I'm JUST clicking a radio button to cause the postback, without entering any data or any other changes into the form...
I checked the older version of the form, which does not use Dynamic Data, and the viewstate doesn't grow at all... so I'm theorizing that the dynamic data controls are somehow to blame...
Anyone else seen this? Is there a fix for it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道您的问题的直接答案,但也许这些工具之一可以帮助您进一步诊断:
(1) Fritz Onion 的 ViewState Decoder 工具也许能够帮助您弄清楚里面塞满了什么。 您可以在 Pluralsight 工具页面 中找到列出的 ViewSate Decoder。 直接下载链接:ViewStateDecoder22.zip。
ViewState 解码器屏幕截图 http://alt.pluralsight.com/images/decoderscreenshot.gif
(2) 另一个可能值得关注的工具是 ASP.NET ViewState Helper:
I don't know the direct answer to your question, but perhaps one of these tools may help you diagnose further:
(1) Fritz Onion's ViewState Decoder tool might be able to help you figure out what's getting stuffed in there. You can find ViewSate Decoder listed at the Pluralsight Tools page. Direct download link: ViewStateDecoder22.zip.
ViewState Decoder screen shot http://alt.pluralsight.com/images/decoderscreenshot.gif
(2) Another tool that may be worth looking at is ASP.NET ViewState Helper:
好吧,罪魁祸首是 Telerik 的 RadComboBox。 更具体地说,是缺乏对使用 RadComboBox 的动态数据的支持。 更具体地说:
将 RadComboBox 与 DynamicData 结合使用的解决方法是将可见设置为 false 的 DropDownList,在该 DDL 上调用 PopulateListControl,然后将项目复制到 RadComboBox。
这工作得很好,除非你在每次回发时都这样做......我猜当你这样做时,它会将整个列表填充到 Viewstate 中,并且由于我每次回发都这样做......视图状态不断增长。
Ok, so the culprit was Telerik's RadComboBox. More specifically, it was the lack of support for Dynamic Data using RadComboBox. To be even MORE specific:
The workaround for using a RadComboBox with DynamicData is to have a DropDownList with visible set to false, call the PopulateListControl on that DDL and then copy the items to RadComboBox.
This works fine, except when you do that on every postback... I'm guessing it stuffs the entire list into Viewstate when you do it that way, and since I was doing it every postback... the viewstate kept growing.