Downloading HTTP with VB.NET

Submitted on: 1/2/2015 11:41:00 PM
By: Larry Bray (from psc cd)  
Level: Intermediate
User Rating: By 6 Users
Compatibility: VB.NET
Views: 2845
     Explains how to download http with VB.NET, includes a simple example.


Downloading using HTTP with VB.NET is a fairly simple task. It really only takes four steps:

1 - Use the Create method of the System.Net.WebRequest class to specify the web page. This method will return a HttpWebRequest if the web page is http://, it will return a FileWebRequest if the web page is file://.
2 - Use the GetResponse method of the WebRequest object and return a WebResponse object for the web page.
3 - Create a StreamReader or BinaryReader depending on the type of data to be downloaded.
4 - The specifics that you need to perform on the stream.

The following example simply displays the html of a web page -

First, import System.Net and System.IO

Public Module Download
 Public Sub Main()
 Dim PgReq As HttpWebRequest = CType(WebRequest.Create(, HttpWebRequest)
 Dim PgResp As WebResponse = PageRequest.GetResponse()
 Dim sr As New StreamReader(PgResp.GetResponseStream())
 Dim Pg As String = sr.ReadToEnd()
 End Sub
End Module

Other 2 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.