如何最大限度地减少在asp.net页面的视图状态的大小? [英] How to minimize viewstate size of a page in asp.net?

查看:154
本文介绍了如何最大限度地减少在asp.net页面的视图状态的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何最大限度地减少在asp.net页面的视图状态的大小?
请帮助。

How to minimize viewstate size of a page in asp.net? Please help.

推荐答案

您有几种选择,以减少ViewState的:

You have several options to reduce the ViewState:


  • 停用的ViewState 对于不需要它的控制(这是最有效的解决方案)。例如。如果你可以缓存在服务器上的一些数据,那么你可以重新绑定任何数据绑定控件与每一个请求,它并不需要保存一切都在ViewState中。

  • 打开HTTP COM pression服务器(IIS)。这减少发送到客户端的页的大小,包括视图状态。

  • 的COM preSS ViewState中。这具有通过HTTP玉米pression一个额外的优点:它也减少回发的大小(发送回服务器的数据)时,由于回发期间视图状态始终发送回服务器。这有各种方法,例如如图<一href=\"http://aspadvice.com/blogs/mamanzes_blog/archive/2006/08/27/Save-some-space_2C00_-com$p$pss-that-ViewState.aspx\">this博客文章。

  • 商品ViewState的服务器上,而不是在一个隐藏字段与页面发送。要做到这一点最简单的方法就是使用SesionPageStatePersister,但也有其ViewState中,而不是存储在磁盘使用Session的其他解决方案(在这里看到,例如)。

  • Disable ViewState for controls that do not need it (this is the most effective solution). E.g. if you can cache some data on the server, then you can re-bind any databound controls with every request and it's not needed to save everything in ViewState.
  • Turn on HTTP compression on the server (IIS). This reduces the size of the page sent to the client, including the ViewState.
  • Compress the ViewState. This has an additional advantage over HTTP compression: it also reduces the size of PostBacks (data sent back to the server), since the ViewState is always sent back to the server during a PostBack. There are various approaches for this, e.g. as shown in this blog post.
  • Store the ViewState on the server instead of sending it in a hidden field with the page. The easiest way to do this is to use the SesionPageStatePersister, but there are other solutions which store the ViewState to disk instead of using the Session (see here for example).

这篇关于如何最大限度地减少在asp.net页面的视图状态的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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