Is it not possible to retreive session variables created in a Sub in a Public Shared Function? I get the following error message:
"BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class".
I underlined the code where the error occurrs.
Heres the code:
Has the problem anything to do with that I have both the sub to set the session variable AND the function to retreive the variable in the same class?
Any thoughts appreciated!
"BC30369: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class".
I underlined the code where the error occurrs.
Heres the code:
Code:
Sub GetLoggedInUser()
Dim userID As String
Dim strFullName As String
strFullName = User.Identity.Name
Get just the corpId (remove the domain info)
userID = strFullName.Substring(strFullName.IndexOf("\", 0) + 1)
Session("sUserId") = userID
End Sub
Public Shared Function HasPermission() As Boolean
Dim myCheck As New PermissionCheckClass this is the class where the code is located
myCheck.GetLoggedInUser()
Get the users CorpId from the session variable.
Dim pCorpId As String = CType([U]Session[/U].Item("sUserId"), String)
End Function
Has the problem anything to do with that I have both the sub to set the session variable AND the function to retreive the variable in the same class?
Any thoughts appreciated!