Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I"m trying to read a cookie from the clinet machine using the code:

 

If not Request.Cookies("shoresh")("newmasinblogs") is nothing Then

If Request.Cookies("shoresh")("newmasinblogs") = "כן" Then

massagenum.Text = dataset.Tables("massages").Rows.Count

CheckBox1.Checked = True

End If

End If

 

the problem is that i get error massege:

"Object reference not set to an instance of an object."

 

i just can't solve the problem,

 

i tried to rewrite the cookies, i tried to set it to nothing and then to rewrite it... nothing working.

 

do somebody knows what the problem is?

Posted

Try changing the first line to the following:

 

If Not Request.Cookies("shoresh") Is Nothing AndAlso Request.Cookies("shoresh")("newmasinblogs") Is Nothing Then

 

Not sure if this helps.

Posted

it is more then 0,

 

it's 3 or 4.

 

i get the error massage even in the first checking of the cookies... (if request.cookies... is nothing....)

Posted

may be when i set the cookies to nothing i caused a problem?

 

i tried to import "server.web.httpcookies",

 

it is just not working!!!

  • Administrators
Posted

How about if you did

If (not Request.Cookies("shoresh") is nothing) andalso (not Request.Cookies("shoresh")("newmasinblogs") is nothing) Then
   If Request.Cookies("shoresh")("newmasinblogs") = "כן" Then
       massagenum.Text = dataset.Tables("massages").Rows.Count
       CheckBox1.Checked = True
   End If
End If

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • Administrators
Posted

in your original code

If not Request.Cookies("shoresh")("newmasinblogs") is nothing

it will try to evaluate Cookies("shoresh")("newmasinblogs") but if Cookies("shoresh") is nothing then it will fail, doing it in two stages makes sure both parts aren't nothing.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...