Checking for a session variable... returns (Object reference not set to an instance of an object.)
- by Chocol8
In the Session_Start i have
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Session("login") = False
End Sub
and in a custom .aspx page i included the following...
Public ReadOnly Property GetLoginState() As Boolean
Get
If Current.Session("login") Is Nothing Then
Current.Session("login") = False
End If
Return Current.Session("login")
End Get
End Property
Why i am getting error the error
Object reference not set to an instance of an object.
at line
If Current.Session("login") Is Nothing Then
while checking for the login state as follows?
If GetLogin = False Then
'Do something
End if
I mean i have already created the instance on the Session_Start... Haven't i?
What am i doing wrong here?