I have hit a small snag when it comes to the average life expectancy of and keeping its viewstate around. should I really keep it around anymore than a couple of hours. I understand that the point of viewstate was to have a way to rebuild the control tree with out having to keep the information on the server.
But the increasing size of viewstate to client is becoming alarmingly large on the complex and large web applications.
a solution that a friend of mine sugested is that if we use SQL server as a storage medium only keep viewstate up to 24 hours and then simply delete them. Or through a configuration in the web config
This is a solution for stripping out viewstate before it hits the client. The thought for making this utility was the following, viewstate has no real use fullness on they client besides reconstructing the control tree and as a state bag. Most of the time developers turn viewstate off on controls because it tends to become huge and slows down the streaming of content.
Even when using Ajax API’s such as Microsoft Ajax and Anthem.Net viewstate is still passed back and forth. So even though we get partial page updates we are still passing through that big chunk back and forth, watch we have done is we have disguised the problem but not solve it.
What has been done is eliminated viewstate being sent out to the client and being stored in another medium.
Current Supported mediums:
- SQL Database
SQLDatabase is inserting viewstate into a table given certain keys.
Session was chosen as a storage method also after a friend asked me “so what are you doing sticking it in session?”….I answered no. Then it got me to thinking well…what if i do store it in session…what would be so bad? Session…well what would be the impact of the different flavors of session..
- InProc Session: I would avoid a round trip to the server and it would be saved in memory…If i also compress it it shouldn’t be so bad.
- Session State Server: In this case i piggy back of the session state server and double it as a viewstate server as well.
The Session & Database methods helps the issue of retrieving the right viewstate from a web farm.
So I have put a W.I.P version on codeplex that i will be updating on the weekend….I know right now its not Pure OO … its not something that Jean-Paul S Boodhoo would approve lol