G
Guest
Hi all,
I'm having a very strange problem. The third line in the following code
gives me a null reference exception when used in an ASP.Net web page. The
code is called on the click of a button.
Public Overridable Property SDSVarsSetup() As Boolean
Get
If Not IsNothing(Session("SDSVarsSetup")) Then ' <-- **Exception
occurs here**
Return CType(Session("SDSVarsSetup"), Boolean)
Else
Return Nothing
End If
End Get
Set(ByVal Value As Boolean)
If Not IsNothing(HttpContext.Current) Then
Session("SDSVarsSetup") = Value
End If
End Set
End Property
I don't understand how a null reference exception can occur when I'm
checking for a null reference condition. I have checked the code at a
different stage of the page life cycle (i.e. Load) and the values are present
and work fine. It appears to be a problem with the Handle Postback Events
stage. Does anyone know why this might happen?
Thank you very much.
I'm having a very strange problem. The third line in the following code
gives me a null reference exception when used in an ASP.Net web page. The
code is called on the click of a button.
Public Overridable Property SDSVarsSetup() As Boolean
Get
If Not IsNothing(Session("SDSVarsSetup")) Then ' <-- **Exception
occurs here**
Return CType(Session("SDSVarsSetup"), Boolean)
Else
Return Nothing
End If
End Get
Set(ByVal Value As Boolean)
If Not IsNothing(HttpContext.Current) Then
Session("SDSVarsSetup") = Value
End If
End Set
End Property
I don't understand how a null reference exception can occur when I'm
checking for a null reference condition. I have checked the code at a
different stage of the page life cycle (i.e. Load) and the values are present
and work fine. It appears to be a problem with the Handle Postback Events
stage. Does anyone know why this might happen?
Thank you very much.