Code Repo    |     RSS
MD's Technical Sharing



Thursday, July 24, 2008

.NET send a GET HttpWebRequest and retrieve the server response

'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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.