|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with WebClient and Cookiesthat demonstrates the problem I'm having. This is my ASP.NET page code: ***** CODE ***** Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim cookie As HttpCookie = Request.Cookies("mykey") If Not IsNothing(cookie) Then Response.Write("Cookie value is: " & cookie.Values("mykey")) Else Response.Write("Cookie is Nothing") End If End Sub ***** /CODE ***** This is my VB.NET code: ***** CODE ***** Imports System.IO Imports System.Net Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim client As WebClient = New WebClient() client.Headers.Add(HttpRequestHeader.Cookie, "mykey=myvalue") Dim data As Stream = client.OpenRead("http://localhost/JunkCookieTest/Default.aspx") Dim reader As StreamReader = New StreamReader(data) data.ReadTimeout = 6000 txtOutput.Text = reader.ReadToEnd() client.Dispose() End Sub ***** /CODE ***** It seems that as long as the word "mykey" exists in the client.Headers.Add..... line I don't recieve "Cookie is Nothing" but I can't figure out how to assign it a value. My value is always blank. |
|||||||||||||||||||||||