Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27189

VS 2010 Looking for 200 from httpwebrequest

$
0
0
Hey Guys,

What i'm doing here is after i do an httpwebrequest i am looking to make sure we get a 200 ok before continuing, in the test code i have:

Code:

                '// [GET] REQUEST
                Dim GETRequest As HttpWebRequest = CType(WebRequest.Create(searchURL), HttpWebRequest)
                '// ADDITIONAL INFORMATION
                With GETRequest
                    .Method = "GET"
                    .Accept = "*/*"
                    .UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
                    .KeepAlive = True
                End With
                '// THE RESPONSE
                Dim GETResponse As WebResponse = GETRequest.GetResponse()
                '// GET THE STREAM BACK FROM THE SERVER
                Dim GETdataStream As Stream = GETResponse.GetResponseStream()
                '// STREAMREADER
                Dim GETreader As New StreamReader(GETdataStream)
                '// READ THE CONTENTS
                Dim GETresponseFromServer As String = GETreader.ReadToEnd()
                MessageBox.Show(GETResponse.ToString)
                '// RESPONSE 200 OK
                If GETResponse. = HttpStatusCode.OK Then
                    'MessageBox.Show(ControlChars.Lf + ControlChars.NewLine + "Response Status Code is OK and StatusDescription is: {0}", GETResponse.StatusDescription)
                End If

This is the part i can't figure out i get an error:

Code:

                If GETResponse.statusCode = HttpStatusCode.OK Then
                    'MessageBox.Show(ControlChars.Lf + ControlChars.NewLine + "Response Status Code is OK and StatusDescription is: {0}", GETResponse.StatusDescription)
                End If

The command statusCode doesn't exist i even pasted the code from another website.

Any help would be appreciated :)

cheers guys

Graham

Viewing all articles
Browse latest Browse all 27189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>