What's wrong with this code? HttpWebRequest

R

Richard Aubin

The following code is supposed to fetch an this page from the specified url
then display the contents.

The only problem is that I'm only getting the following as the response,
when the page is actually much longer:

<html>
<head>

----

Console Application

Imports System
Imports System.IO
Imports System.Net

Module Module1

Sub Main()
'Address of URL
Dim URL As String = http://www.csharpcorner.com/default.asp
Dim request As WebRequest = WebRequest.Create(URL)
Dim response As WebResponse = request.GetResponse()
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
Dim str As String = reader.ReadLine()

Do While str.Length > 0
Console.WriteLine(str)
str = reader.ReadLine()
Loop

Console.ReadLine("press enter to continue)

End Sub

End Module
 
R

Richard Aubin

Nevermind, found out what it was...

Do While str.Length > 0

It encounted an empty line ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top