[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


ASP.net VB.net read http response

Posted on 2012-08-21
Medium Priority
Last Modified: 2012-08-21

I am using the the procedure below to read the response from a post that
I made to a URL.
THe following three lines only return a few characters. I am not sure that I am getting
everything from the response.
Is there a way to get more?from a site that returns hotel booking information. Thanks

The reason I ask is because this is
       Dim Answer As Stream = WebResp.GetResponseStream()
        Dim _Answer As New StreamReader(Answer)

    Private Shared Sub start_get()
        'Our getVars, to test the get of our php.
        'We can get a page without any of these vars too though.
        Dim getVars As String = "?var1=test1&var2=test2"
        'Initialization, we use localhost, change if applicable

        Dim WebReq As HttpWebRequest = DirectCast(WebRequest.Create(String.Format("https://test.eres-dev.com/connect/eres/api/2008a", getVars)), HttpWebRequest)
        'This time, our method is GET.
        WebReq.Method = "GET"
        'From here on, it's all the same as above.
        Dim WebResp As HttpWebResponse = DirectCast(WebReq.GetResponse(), HttpWebResponse)
        'Let's show some information about the response

        'Now, we read the response (the string), and output it.
        Dim Answer As Stream = WebResp.GetResponseStream()
        Dim _Answer As New StreamReader(Answer)

        'Congratulations, with these two functions in basic form, you just learned
        'the two basic forms of web surfing
        'This proves how easy it can be.
    End Sub
Question by:Murray Brown
  • 2
  • 2
LVL 83

Expert Comment

ID: 38317744

You are doing a readtoend which means you read the whole stream that was returned by the server.

Author Comment

by:Murray Brown
ID: 38317802
Thanks. What code would I use to read each line?
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 38317863
Split the string on VBCRLF.

For each Line As String in _Answer.ReadToEnd().Split(VBCRLF)
   msgbox Line

Author Closing Comment

by:Murray Brown
ID: 38317884
Great. Thank you

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question