Sunday, 12 August 2012

HttpWebRequest and HttpWebResponse in

In this tutorial, we cover using the HttpWebRequest and HttpWebResponse. We use it to obtain the source code of a web page that I have created. We also use the Stream Reader to read the text and then place it into a textbox. In this application you get source code of html file in the textbox simple to use make complex in this application is under stand (the HttpWebRequest and HttpWebResponse). Copt and paste below Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(TextBox2.Text)
        Dim response As System.Net.HttpWebResponse = request.GetResponse()

        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

        Dim sourcecode As String = sr.ReadToEnd()

        TextBox1.Text = sourcecode
    End Sub

End Class