Programming Tutorials

How to read URL Content through code

By: Issac in Tutorials on 2009-02-21  

When we want to read content of an HTML page from a remote webserver, in we are using WebRequest, WebResponse. WebResponse return a StreamReader and we can get the content from StreamReader.


Imports System.Net
Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim inStream As StreamReader
        Dim webRequest As WebRequest
        Dim webresponse As WebResponse
        webRequest = webRequest.Create(TextBox1.Text)
        webresponse = webRequest.GetResponse()
        inStream = New StreamReader(webresponse.GetResponseStream())
        TextBox2.Text = inStream.ReadToEnd()
    End Sub
End Class

You have to write this code in the button click event so that if we click the Get Page button we will get the URL content.

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in )

Latest Articles (in