| 1 | public class Webclient3 |
| 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 b as byte() |
| 8 | Dim res as byte() |
| 9 | |
| 10 | 'enncode the form data string into a byte array |
| 11 | b = System.Text.Encoding.ASCII.GetBytes("text=test text&password=secret&checkbox=on&textarea=a longer text sentence&submit=submit") |
| 12 | |
| 13 | 'set the content type of the data |
| 14 | wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded") |
| 15 | |
| 16 | 'scrapte the data |
| 17 | res = wc.UploadData("http://authors.aspalliance.com/damianm/article/4/3/formreader.aspx", b) |
| 18 | |
| 19 | 'convert the return page from a byte array to ascii and display |
| 20 | Literal1.Text = System.Text.Encoding.ASCII.GetString(res) |
| 21 | End Sub |
| 22 | |
| 23 | End class |