• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

ASP.NET/VB: HttpWebRequest without errors

What am I doing wrong?
<%@ Page Language="VB" %>
<%

 Dim request = HttpWebRequest.Create("http://www.example.com")
 Dim response = request.GetResponse()
 Response.write(response)

%>

Open in new window

0
hankknight
Asked:
hankknight
1 Solution
 
pateljituCommented:
Please try this code change:

 <%
        Dim request = System.Net.HttpWebRequest.Create("http://www.example.com")
        Dim Objresponse = request.GetResponse()
        
        
        Dim webStream As System.IO.Stream = Objresponse.GetResponseStream() ' Get Response

        Dim reader As New System.IO.StreamReader(webStream)
        ' Read the content.
        Dim responseFromServer As String = reader.ReadToEnd()
        
        Response.Write(responseFromServer.ToString())

       Response.Write(Server.HtmlEncode(responseFromServer.ToString()))  ' Raw HTML
        %>

Open in new window

0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now