Generic ASP.NET Session Wrapper
4
This class uses generics and provides functions that wrap writing to and reading from an ASP.NET session.
Public Class SessionHelper(Of T)
#Region "External Methods"
Public Shared Function ReadSessionItem(ByVal name As String) As T
Dim value As T = Nothing
value = CType(System.Web.HttpContext.Current.Session(name), T)
Return value
End Function
Public Shared Sub WriteSessionItem(ByVal name As String, ByVal value As T)
Dim item As Object = System.Web.HttpContext.Current.Session(name)
If item Is Nothing Then
System.Web.HttpContext.Current.Session.Add(name, value)
Else
System.Web.HttpContext.Current.Session(name) = value
End If
End Sub
#End Region
End Class






There are currently no comments for this snippet.