To resolve this behavior, check for NULL values that are associated with cookies, as shown in the following sample codes:
Microsoft Visual C# .NET
HttpCookie cookie = Request.Cookies["SomeCookie"];
if(cookie == null)
{
//CookieValue represents a WebForm Label control
CookieValue.Text = "Cookie does not exist!";
}
else
{
//CookieValue represents a WebForm Label control
CookieValue.Text = cookie.Value;
}
Microsoft Visual Basic .NET
Dim cookie As HttpCookie = Request.Cookies("SomeCookie")
If cookie Is Nothing Then
'CookieValue represents a WebForm Label control
CookieValue.Text = "Cookie does not exist!"
Else
'CookieValue represents a WebForm Label control
CookieValue.Text = cookie.Value
End If