A
Arpan
An ASPX page has the following code:
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
If Not (IsNothing(Request.Cookies("AuthCookie"))) Then
Response.Write(Request.Cookies("AuthCookie").Value)
Else
Response.Write(Cookie 'AuthCookie' Doesn't Exist!)
End If
End Sub
Assume that the cookie named "AuthCookie" doesn't exist. As expected,
the Response.Write line in the Else condition gets rendered but if I
change the If condition to
If Not (IsNothing(Request.Cookies("AuthCookie").Value)) Then
then ASP.NET generates the following error:
Object reference not set to an instance of an object.
Why? Is it because Request.Cookies("AuthCookie").Value evaluates to an
expression?
Thanks,
Arpan
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
If Not (IsNothing(Request.Cookies("AuthCookie"))) Then
Response.Write(Request.Cookies("AuthCookie").Value)
Else
Response.Write(Cookie 'AuthCookie' Doesn't Exist!)
End If
End Sub
Assume that the cookie named "AuthCookie" doesn't exist. As expected,
the Response.Write line in the Else condition gets rendered but if I
change the If condition to
If Not (IsNothing(Request.Cookies("AuthCookie").Value)) Then
then ASP.NET generates the following error:
Object reference not set to an instance of an object.
Why? Is it because Request.Cookies("AuthCookie").Value evaluates to an
expression?
Thanks,
Arpan