Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET/VB: Get Result Returned by HttpWebRequest

Posted on 2013-12-18
1
Medium Priority
?
541 Views
Last Modified: 2013-12-18
I use the following code to post data to a remote website.  How can I get and output the response from the remote website?
<%@ Page Language="VB"%>
<%@Import namespace="System"%>
<%@Import namespace="System.Web"%>
<%@Import namespace="System.Net"%>
<%@Import namespace="System.IO"%>
<%@Import namespace="System.Text"%>
<%

Dim data as String = "{}"
Dim webRequest As HttpWebRequest = TryCast(WebRequest.Create("http://example.com/"), HttpWebRequest)
webRequest.Method = "POST"
webRequest.ContentType = "application/json"
webRequest.ContentLength = data.Length
webRequest.Accept = "application/json"
webRequest.ReadWriteTimeout = 500000
Dim requestWriter As New StreamWriter(webRequest.GetRequestStream())
requestWriter.Write(data)
requestWriter.Close()


HttpContext.Current.Response.Write("I want the result output here")

%>

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39727582
You need to call the GetResponse() method of your request to get the stream with the response data in, and then read the result from that.

You can use the sample here as a guide: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

718 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