C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






View State Chunking in ASP.NET


Posted Date: 19 Jun 2008    Resource Type: Articles    Category: .NET Framework
Author: shakti singh tanwarMember Level: Diamond    
Rating: Points: 5



Whenever you request a page from a server it responds by sending the generated HTML of the page. Server also stores the form data into a hidden variable with name __VIEWSTATE. This information is needed by server to maintain state of the page across postbacks. On every request the server reads this variable and populates the control with values from previous request, then populates the postback data, fires the event again generates the ViewState and send it with HTML.

Thus the more the controls there are on the page, more will be the size of the Viewstate.

Since this needs a good amount of serialization and deserialization, as a matter of good design, you should always strive to include as little information in view state as possible, which ensures the better performance.

The size of the hidden view state field has no limit. However, some proxy servers and firewalls refuse to let pages through if they have hidden fields greater than a certain size. To avoid this problem view state chunking can be used, which automatically divides view state into multiple fields to
ensure that no hidden field exceeds a size threshold you set.
To use view state, you simply need to set the maxPageStateFieldLength attribute of the <pages>
element in the web.config file. This specifies the maximum view state size, in bytes. Here’s an example
this caps the view state at 2 KB:


<configuration>
<system.web>
<pages maxPageStateFieldLength = "2048" />
</system.web>
</configuration>


When you request a page that generates a view state larger than this, several hidden input fields
will be created:







.
.
.
[/CODE[
View state chunking in no way improves performance. It rather puts some extra serialization efforts and thus should be used only when needed.

You can control the viewstate by setting EnableViewState property available with all ASP.Net server controls but there is an exception to it. Even if you set EnableViewState to false, the control can still hold onto a smaller amount of view state information that it deems critical for proper functioning. This privileged view state information is known as control state, and it can never be disabled. However, in a well-designed control the size required for control state will be significantly smaller than the size of the entire view state.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
View state chunking  .  Reducing size of view state  .  Improving design of asp.net pages  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Differences Between Convert.ToInt and Int.Parse
Previous Resource: Differences between const and readonly
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use