Reputation: 378
I want to load some fixed part from other website to my web application. How to accomplish this? Thanks.
Upvotes: 5
Views: 8587
Reputation: 18501
You could do it in a few ways:
<iframe>
ajax
and write it into the page.WebClient
DownloadString
and write it into your page.Update
After you get your string, you might parse it and grab the stuff you want using the Html Agility Pack . (Also available on Nuget)
Upvotes: 6
Reputation: 66398
You can use WebRequest
for this task:
string url = "http://somesite.com/somepage.php";
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string contents = reader.ReadToEnd();
//parse contents as you wish.......
reader.Close();
}
response.Close();
Upvotes: 5