.NET send a GET HttpWebRequest and retrieve the server response

0.00 avg. rating (0% score) - 0 votes
‘Create the HttpWebRequest object
Dim req as HttpWebRequest = WebRequest.Create(URL)

Try
‘Get the data as an HttpWebResponse object
Dim resp as HttpWebResponse = req.GetResponse()

‘Convert the data into a string (assumes that you are requesting text)
Dim sr as New StreamReader(resp.GetResponseStream())
Dim results as String = sr.ReadToEnd()
sr.Close()

‘… work with results …
Catch wex as WebException
‘Something went awry in the HTTP request!
End Try

0.00 avg. rating (0% score) - 0 votes
ToughDev

ToughDev

A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>