help.net


Musing on .Net

News

Windows Phone Apps I recommend

FotoBank


FotoIreland



hit counters






Open source CMS


My blog

Irish blogs

Locations of visitors to this page Get Chitika eMiniMalls

.Net useful

Blogs I read

PocketPC

SQL

Usability

[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

Posted: Jun 28 2006, 02:45 PM by help.net | with 2 comment(s)
Filed under:

Comments

No Comments