| 1 | public class Webclient5 |
| 2 | Inherits System.Web.UI.Page |
| 3 | protected WithEvents Literal1 as System.Web.UI.WebControls.Literal |
| 4 | |
| 5 | private Sub Page_Load(ByVal sender as System.object, ByVal e as System.EventArgs) Handles MyBase.Load |
| 6 | Dim wc as new System.Net.WebClient() |
| 7 | Dim s as System.IO.Stream |
| 8 | Dim sr as System.IO.StreamReader |
| 9 | |
| 10 | 'set cookie value in header |
| 11 | wc.Headers.Add("Cookie", "value=this is a test;value2=this is another test") |
| 12 | |
| 13 | 'scrape the data |
| 14 | s = wc.OpenRead("http://authors.aspalliance.com/damianm/article/4/5/cookiereader.aspx") |
| 15 | |
| 16 | 'read in the page |
| 17 | sr = new System.IO.StreamReader(s) |
| 18 | Literal1.Text = sr.ReadToEnd() |
| 19 | End Sub |
| 20 | |
| 21 | End class |