Requesting another page from aspx site

can I make a request for another page on the internet from page_load? I mean, if it is possible to get the markup code with information from another page and display them on my aspx site? For example, something like this:

protected void Page_Load(object sender, EventArgs e)
{
  UnknownType anotherSite = GetMarkupCode("www.fifa.com");
  //parse anotherSite
             .
             .
             .
  //display parsed informations
             .
             .
             .
}

      

If possible, how can I do this? Thanks a lot for the answers.

+2


a source to share


3 answers


The user can use the WebClient class.

WebClient webClient = new WebClient();
Stream data = webClient.OpenRead("http://www.fifa.com");
StreamReader streamReader = new StreamReader(data);
string html = streamReader.ReadToEnd();

      



EDIT: Simple version thanks to Lucas

WebClient webClient = new WebClient();
string html = webClient.DownloadString("http://www.fifa.com");

      

+4


a source


Why don't you use an iframe and set the source of the iframe as the requested url of the page?



+1


a source


+1


a source







All Articles