Minimizing View State.

View State can become a big field in a page. if it is from the process that we are now working through or from the fact that we have a huge select box like counties in the US.
so if i have been working with ASP.NET 1.1 then all i whould have to do whould be create a special basePage that derrives from Page and ovverides LoadPageStateFromPersistenceMedium and SavePageStateToPersistenceMedium methods and make them read and write viewstate contents in the session state, in a database, or in any other data location.
but it is not that simple in the ASP.NET 2.0?

well in the ASP.NET 2.0 you have an attribute in the section named maxPageStateFieldLength.
it looks like this
<pages maxPageStateFieldLength="15" />
and sets the ammount of data sent in a <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDASYDsdFJ?e" /> field
if the view state is longer then 15 the view state will be chopped to parts 15 chars each and sent like this:
<pages maxPageStateFieldLength="5" />
<input type="hidden" name="__VIEWSTATEFIELDCOUNT" id="__VIEWSTATEFIELDCOUNT" value="16" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPD" />
<input type="hidden" name="__VIEWSTATE1" id="__VIEWSTATE1" value="wUKLT" />
<input type="hidden" name="__VIEWSTATE2" id="__VIEWSTATE2" value="I2MjI" />
<input type="hidden" name="__VIEWSTATE3" id="__VIEWSTATE3" value="3NDkw" />
<input type="hidden" name="__VIEWSTATE4" id="__VIEWSTATE4" value="NA9kF" />
<input type="hidden" name="__VIEWSTATE5" id="__VIEWSTATE5" value="gICAw" />
<input type="hidden" name="__VIEWSTATE6" id="__VIEWSTATE6" value="9kFgI" />
<input type="hidden" name="__VIEWSTATE7" id="__VIEWSTATE7" value="CCg88" />
<input type="hidden" name="__VIEWSTATE8" id="__VIEWSTATE8" value="KwANA" />
<input type="hidden" name="__VIEWSTATE9" id="__VIEWSTATE9" value="GRk7N" />
<input type="hidden" name="__VIEWSTATE10" id="__VIEWSTATE10" value="FNJbP" />
<input type="hidden" name="__VIEWSTATE11" id="__VIEWSTATE11" value="PZl6t" />
<input type="hidden" name="__VIEWSTATE12" id="__VIEWSTATE12" value="C+gkP" />
<input type="hidden" name="__VIEWSTATE13" id="__VIEWSTATE13" value="/XMyn" />
<input type="hidden" name="__VIEWSTATE14" id="__VIEWSTATE14" value="MRGPs" />
<input type="hidden" name="__VIEWSTATE15" id="__VIEWSTATE15" value="=" />

though this doesnt relly shortens the view state it just disects it to smaller parts.
i belive this one actually enlages the view state with a few more decleraitions of view state fields wich are sent in the HTTP request.
there must be a way to get the view state smaller.
dino esposito is actually claming for faster transfer of the view state object wich i think doesnt exist since we are HTTP over port 80 and just enlarged the ammount of data to send to the server.
give me a week to reserch all of the stuff accumilating under the table and i will be back with some solutions.
one more test to the end of the semester.

Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.