В Сессии мне кажеться не очень эффективно такое хранить, но идея правильная
Private ReadOnly Property ViewStateFilePath() As String
Get
Dim str_fold As String
Dim str_file As String
'//
str_fold = System.Configuration.ConfigurationManager.AppSettings.Item("PersistedViewState") '"c:\proc\PersistedViewState\" 'System.IO.Path.Combine(Request.PhysicalApplicationPath, "PersistedViewState")
str_file = Session.SessionID & "-" & Request.ServerVariables("SERVER_NAME").ToString + Request.ServerVariables("SCRIPT_NAME").ToString.Replace("/", "-") & ".vs"
'//
Return System.IO.Path.Combine(str_fold, str_file)
End Get
End Property
Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
'* determine which file to pull
If Not (System.IO.File.Exists(ViewStateFilePath)) Then
Return Nothing
Else
'* open file
Dim obj_read As System.IO.StreamReader
Dim str_read As String
Dim obj_frmt As System.Web.UI.LosFormatter
'//
obj_read = System.IO.File.OpenText(ViewStateFilePath)
str_read = obj_read.ReadToEnd
obj_read.Close()
obj_frmt = New System.Web.UI.LosFormatter
'//
Return obj_frmt.Deserialize(str_read)
End If
End Function
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
Dim obj_frmt As System.Web.UI.LosFormatter = New System.Web.UI.LosFormatter
Dim obj_stgw As System.IO.StringWriter = New System.IO.StringWriter
Dim obj_strw As System.IO.StreamWriter
'//
obj_frmt.Serialize(obj_stgw, viewState)
'* save file to disk
obj_strw = System.IO.File.CreateText(ViewStateFilePath)
obj_strw.Write(obj_stgw.ToString)
obj_strw.Close()
End Sub
данное сообщение получено с www.gotdotnet.ru
ссылка на оригинальное сообщение