473,385 Members | 1,320 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,385 software developers and data experts.

retrieve web page to string

Hi,

In VB6 I would use the Inet Control to retrieve the contents of a web page to a string. What is the .NET way of doing this?
TIA,

--
Al Reid
Nov 21 '05 #1
2 5504
"Al Reid" <ar*****@reidDASHhome.com> schrieb:
In VB6 I would use the Inet Control to retrieve the contents of a web page
to a string. What is the .NET way of doing this?


\\\
Imports System.IO
Imports System.Net
..
..
..
Public Function LoadTextFile(ByVal Url As String) As String
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As New StreamReader(wrp.GetResponseStream())
Dim Text As String = sr.ReadToEnd()
sr.Close()
wrp.Close()
Return Text
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Herfried,

Thanks so much.

As a newbie to .Net, I missed the System.Net and was looking at System.Web namespace. your code makes perfect sense.

--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:u2*************@TK2MSFTNGP12.phx.gbl...
"Al Reid" <ar*****@reidDASHhome.com> schrieb:
In VB6 I would use the Inet Control to retrieve the contents of a web page
to a string. What is the .NET way of doing this?


\\\
Imports System.IO
Imports System.Net
.
.
.
Public Function LoadTextFile(ByVal Url As String) As String
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As New StreamReader(wrp.GetResponseStream())
Dim Text As String = sr.ReadToEnd()
sr.Close()
wrp.Close()
Return Text
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

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

Similar topics

5
by: Salmo Bytes | last post by:
I want to send an xml string as a get parameter, where the xml is created from a runtime database query. I try to avoid dynamic framesets, but sometimes they're needed: $xml =...
2
by: Ersin Inan | last post by:
Hi All, Is there a way to get page name in asp.net code behind? I use this to log error messages in DB ( and in which page the error occured ) For instance , if it is welcome.aspx , then in C#...
1
by: sonic | last post by:
Hi, Is there a signature that would allow me to set values for such properties as NameValueCollection or StringList within ASPX xml definition ? example: myControl has a Values property of...
2
by: Wolf | last post by:
Hi I want to popup a page, but I want to send a string through to the popup.Then I want to set a multiline Textbox on the popup equal to that string.Can anyone help me with it please
0
by: ravescar | last post by:
I am currently working on an generic error collection mechanism in ASP.NET2.0 written using C# that can catch unhandled exception on a web application in application level. it automatically save an...
2
by: Jon Paal | last post by:
..net 2.0 can't retrieve connection string from web.config, always returns error message -- what's missing ?? ======web.config ========= <appSettings> <connectionStrings> <add...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
0
by: riskebiz | last post by:
Hi Everyone, I'm trying to put in a loop so the following program keeps looping through the HTML content on a page and returns all of the results, not just the first one. Right now the code does...
4
by: Krishbiztech | last post by:
Hi all.. I'n new to this forum.. Its a basic thing only.. bt i cudnt find the fault.. i'm passing two query strings in my asp.net page.. its something like this...
1
by: inlovewithmusic | last post by:
Hi , I am trying to write a piece of funtionality that will store a string array into into a database and then later retrieve it for viewing later. I wrote the funtionality to insert the...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.