[ASP.NET 1.x] Storing ViewState in Session State
A very good tip from MSDN magazine (July 2006). If you want to keep your ASP.NET pages lighter why not keeping lengthy ViewState in memory instead of the page.
Tested, works perfectly well. One question, is it scalable? I mean what's happens with hundreds of simultaneous users?
The magazine has the C# code, so here we go with the VB.Net override functions:
UPDATE: Well it's a bad idea, I got too much timeout issues, see the comment below for more explanations.
Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object Dim key As String = Request.RawUrl + "_VIEWSTATE" Dim state As Object = Session(key) If state Is Nothing Then Return MyBase.LoadPageStateFromPersistenceMedium() Else Return state End If End Function
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object) Dim key As String = Request.RawUrl + "_VIEWSTATE" Session(key) = viewState End Sub