How to minimize viewstate size of a page in asp.net? Please help.
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
You have several options to reduce the ViewState:
I chose to save the view state on the server in a database itself and not allow it to be passed in the HTML to the client which bloats the page size. You can extend the HiddenFieldPageStatePersister and work around this. I have written a detailed article around this if you wish ...
http://ashishnangla.com/2011/07/21/reducing-size-of-viewstate-in-asp-net-webforms-by-writing-a-custom-viewstate-provider-pagestatepersister-part-12/
Most of the points are highlighted within the other answers. Here's one that might be helpful:
Reduce the number of server controls (e.g. web/html controls) especiall those you do not need. Use simple HTML markups instead.
I've seen too many cases of redundant Table/Row/Cell Web Controls where normal < table >, < tr > and < td > will do.
add the above code in the code behind of the page that generates large viewstate values. This allows storing the viewstate in the session. Only a key for the viewstate should be added now.
You cannot minimize the size of the ViewState. It's ASP.NET which serializes/deserializes. Though you could selectively disable ViewState for controls that don't need it.
You can turn on compression on the server to minimalize size of data transfered through the network or save viewState to disk and never send it to the client.