Re: HTTP Object and Retrieving HTML Programatically
- From: Alexey Smirnov <alexey.smirnov@xxxxxxxxx>
- Date: Thu, 25 Oct 2007 19:21:46 -0000
On Oct 25, 8:41 pm, Paul <P...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am using ASP.Net 2.0 and VB.Net (although C#is ok also).
I want to create an object/method/function that will take a URL as an input
parameter and then return all of the HTML in that page.
I also want to return the HTTP header information (response object).
Does anyone have an insight as to any code samples or .Net objects I would
use to accomplish this?
TIA
Use WebRequest:
Dim PageUrl As String = "http://..."
Dim req As HttpWebRequest = CType(WebRequest.Create(PageUrl),
HttpWebRequest)
Dim enc As Encoding = Encoding.GetEncoding(1252)
Dim r As HttpWebResponse
Dim s As System.IO.StreamReader
r = CType(req.GetResponse(), HttpWebResponse) ' This is your response
s = New System.IO.StreamReader(r.GetResponseStream(), enc)
Dim html As String = s.ReadToEnd()
r.Close()
s.Close()
Response.Write(html)
.
- Prev by Date: Re: System.Web.Mail.MailMessage Headers.Add - Include vbCrLf
- Next by Date: Re: File upload woes
- Previous by thread: Re: GridView not displaying on page after postback
- Next by thread: Re: HTTP Object and Retrieving HTML Programatically
- Index(es):
Relevant Pages
|
Loading