Connecting Tech Pros Worldwide Help | Site Map

What's wrong with this code? HttpWebRequest

  #1  
Old November 21st, 2005, 12:26 AM
Richard Aubin
Guest
 
Posts: n/a
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


  #2  
Old November 21st, 2005, 12:26 AM
Richard Aubin
Guest
 
Posts: n/a

re: What's wrong with this code? HttpWebRequest


Nevermind, found out what it was...

Do While str.Length > 0

It encounted an empty line ;)


"Richard Aubin" <rcaubin@safe-mailDOTnet> wrote in message
news:OiJHF2BgEHA.1656@TK2MSFTNGP10.phx.gbl...[color=blue]
> The following code is supposed to fetch an this page from the specified[/color]
url[color=blue]
> 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[/color]
StreamReader(response.GetResponseStream())[color=blue]
> 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
>
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
does anyone see what is wrong with my .gif download logic? no matter what image url i try it downloads a junk file that can't be opened in any paint program. dr answers 6 February 20th, 2007 04:15 AM
HttpWebRequest Operation Has Timed Out After Numerous Requests #2 Alex Papadimoulis answers 0 January 30th, 2006 09:15 PM
HttpWebRequest Operation Has Timed Out After Numerous Requests Alex Papadimoulis answers 0 January 29th, 2006 05:55 PM
HttpWebRequest/HttpWebResponse problem... Satinderpal Singh answers 1 July 21st, 2005 03:58 PM