The Session property is a member of classes which implement
System.Web.IHttpHandler System.Web.IHttpModule, and is a part of the
System.Web.HttpContext passed to an IHttpHandler or IHttpModule, such as
System.Web.UI.Page.
Assuming that your class is supposed to work in the context of a Page, you
can obtain a reference to the current Session via the static
System.Web.HttpContext.Current.Handler property. Example:
Dim Session as System.Web.SessionState.HttpSessionState
If Not IsNothing(System.Web.HttpContext.Current.Handler) Then
Session = CType(System.Web.UI.Page)
System.Web.HttpContext.Current.Handler
Return Session("GroupId")
End If
Return ""
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
"Adam Knight" <ad**@pertrain.com.au> wrote in message
news:eS*************@TK2MSFTNGP12.phx.gbl...
Hi all,
I am trying to compile an assembly.
#Code Snippets.
Imports System
Imports System.Web.SessionState.HttpSessionState
Public Function GetGroup() As String
Return Session("GroupId")
End Function
cd mypath
vbc /t:library /r:System.dll /r:System.Web.dll
/out:../../../bin/Security.dll security.vb
pause
I keep getting an error 'Session' is undefined.
Can someone enlighten me as to what i am doing wrong?