eeyo
asked on
How do I get the content from an HTTPclient POST in VB.NET?
How do I get the content from an HTTPclient POST in VB.NET?
Here is what I have tried so for in my Winform Application. In this example, I am trying to send 2 values, and I want to send the result to "responseString".
BTW, the above code is what I cobbled together from websearches, but if I the amount of data expected is relatively small, perhaps it would be easier to come with a solution that isn't asynchronous?
Here is what I have tried so for in my Winform Application. In this example, I am trying to send 2 values, and I want to send the result to "responseString".
Dim client As HttpClient = New HttpClient
Dim values As New Dictionary(Of String, String) From {{"Input1", "hello"}, {"Input2", "world"}}
Dim content As Object = New FormUrlEncodedContent(values)
Dim response As Task(Of HttpResponseMessage) = client.PostAsync("http://www.website.com/webform.aspx", content)
Dim responseString As String = response.Content.ReadAsStringAsync
MessageBox.Show(responseString)
I am currently getting my error at "response.content", probably becuase I am not sure how to handle a "Task(Of HttpResponseMessage)":Dim responseString As String = response.Content.ReadAsStringAsync
BTW, the above code is what I cobbled together from websearches, but if I the amount of data expected is relatively small, perhaps it would be easier to come with a solution that isn't asynchronous?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window
Here is the vb.net code. The responseInString text is the same. Doesn't seem to be changed by the input1 or input2 values.Open in new window