Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Brooklyn Smith   on Feb 16 In Asp.net Category.

  
Question Answered By: Michael Evans   on Feb 16

I got answer but it is also not working on my machine
and gives following error :

The underlying connection was closed: Unable to connect to the remote
server

And code used is (VB.NET) :


<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E) {
myPage.Text = readHtmlPage
("http://aspalliance.com/stevesmith/");
}

private String readHtmlPage(string url)
{
String result;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
</script>
<html>
<body>
<b>This content is being populated from a separate HTTP request to
<a
href="http://aspalliance.com/stevesmith/">http://aspalliance.com/steve
smith/</a>:</b><hr/>
<asp:literal id="myPage" runat="server"/>
</body>
</html>

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to Get Data from other's web site (Screen Scraping ?) Or get search suggestion and latest updates.


Tagged: