HttpCookie Error.

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
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
 
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
 
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

Similar Threads

query registry from aspx page 3
error 7
Server Error Understanding 2
Easy Question 1
Configuration Error Message 8
Error in vb .net 0
"SendUsing" configuration value is invalid. 1
can't reference page anymore? 1

Back
Top