chpicker
Programmer
- Apr 10, 2001
- 1,316
Can anyone explain to me why this code does not work in VB.NET?
This line gives a Server Error: Unable to cast object of type 'System.String' to type 'System.Web.HttpCookie'.
If I change it to "As String" the line works.
Why is Request.Cookies a collection of strings and not a collection of cookies? IntelliSense tells me it's a collection of cookies, but it's not.
How can I do a simple iteration through the cookies for name/value pairs?
Version Information: Microsoft .NET Framework Version 2.0.50727.42; ASP.NET Version 2.0.50727.210
Ian
Code:
[COLOR=blue]For Each[/color] myCookie [COLOR=blue]As[/color blue] HttpCookie [COLOR=blue]In[/color] HttpContext.Current.Request.Cookies
If I change it to "As String" the line works.
Why is Request.Cookies a collection of strings and not a collection of cookies? IntelliSense tells me it's a collection of cookies, but it's not.
How can I do a simple iteration through the cookies for name/value pairs?
Version Information: Microsoft .NET Framework Version 2.0.50727.42; ASP.NET Version 2.0.50727.210
Ian