473,322 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

What's wrong with this code? HttpWebRequest

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
Nov 21 '05 #1
1 4754
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:Oi**************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Janus Knudsen | last post by:
Hello... Need a little explanation! Snippet from MSDN: "The following recommendations will help you use the classes contained in System.Net to their best advantage: Use WebRequest and...
1
by: sfoxover | last post by:
Hi, Could someone please give me some suggestions on how to make this class robust. I need to be able to handle around 20 similtanious requests to this class which causes a web browser to...
3
by: PeterK | last post by:
With the code below, which I copied from the MSDN, I am getting only part of the the web-page 'MyUrl' returned (this is a synchronoues access). My hunch is that I have to use asynchronous access,...
5
by: Not4u | last post by:
Hello, Someone is using HttpWebRequest to automaticly post datas or retrieve datas from my site. How can i stop pages to be get by the HttpWebRequest method ? I know that pages get with...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, i make more than one request and needs to handle cookies being added and removed between requests, just like a regular...
0
by: Tarun | last post by:
I Have tried to fetch some XML data through screen scraping by the following code: System.Net.ServicePointManager.CertificatePolicy = New MyCertificatePolicy dim path as String="" Try Dim req...
6
by: dr | last post by:
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. System.Net.WebRequest myRequest =...
2
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It...
0
by: DiverSteveMO | last post by:
Has anyone got HTTPWebRequest and passing a post to an authenticated site to work on a Intel Dual Core Vista Business machine.? We expect approx. 7Kbytes but afer approx. 3K the code then hangs ...
15
by: Nightcrawler | last post by:
I am currently using the HttpWebRequest and HttpWebResponse to pull webpages down from a few urls. string url = "some url"; HttpWebRequest httpWebRequest =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.