HttpCookie Error.

T

Terry Olsen

I don't understand the error i'm getting on this page. Is this a bug or
am I doing something wrong?


Exception Details: System.InvalidCastException: Unable to cast object of
type 'System.String' to type 'System.Web.HttpCookie'.

Source Error:

Line 24:
Line 25: For Each ckie As System.Web.HttpCookie In
Request.Cookies
Line 26: If ckie.Name = "uid" Then
Line 27: Session.Item("uid") = ckie.Value

Source File: c:\inetpub\index.aspx.vb Line: 25
 
G

Guest

Howdy,

-- begin vbsuxx code :) --
Dim cookie As HttpCookie

' more efficient approach
For i As Integer = 0 To Request.Cookies.Count
cookie = Request.Cookies(i)
Next

' another approach
For Each key As String In Request.Cookies.AllKeys
cookie = Request.Cookies(key)
Next

-- end vbsuxx code

hope it helps

Milosz
 
G

Guest

Sorry, small bug (i'm c# guy and i don't program vb often), should be :

For i As Integer = 0 To Request.Cookies.Count - 1
cookie = Request.Cookies(i)
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,349
Latest member
RebbecaHen

Latest Threads

Top