Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
Tutorial RSS
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
Charts
Controls
Database
Email
Error Handling
File
Graphics
Website Navigation
Network
Performance
User Interface and Themes
Validation
Visual Web Developer
Web Services
XML
Suggest Tutorial


Navigator: Home - Tutorials - Controls - WebClient to retrieve web page from URL in ASP.NET(C#)
WebClient to retrieve web page from URL in ASP.NET(C#)

ASP.Net 4.0 Tutorials V4
Server Intellect Cloud Hosting

ASP.NET Controls Tutorial

This tutorial will show you how to use WebClient to retrieve web page with C# in ASP.NET 2.0. The .NET framework provides an easy to use interface for retrieving resources from a specified URL.

Use WebClient Control to perform linking and loading specified URL.

Design three controls in the web page. There are a TextBox, a Button and a Label

We used over 10 web hosting companies before we found Server Intellect. Their dedicated servers and add-ons were setup swiftly, in less than 24 hours. We were able to confirm our order over the phone. They respond to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.

Add WebClient Control, a Click Button to the web page

WebClient objWebClient = new WebClient();

lblHTML.Text = lblHTML.Text+strHeader + "-" + objWebClient.Headers[strHeader] + "<br>";

foreach (string strHeader in objWebClient.Headers)
{
lblHTML.Text = lblHTML.Text+strHeader + "-" + objWebClient.Headers[strHeader] + "<br>";
}
UTF8Encoding objUTF8 = new UTF8Encoding();
string strRequestHTML = objUTF8.GetString(objWebClient.DownloadData(txtUrl.Text));

lblHTML.Text = "<p><b>Response Header Information:</b>";
foreach(string strHeader in objWebClient.ResponseHeaders)
{
lblHTML.Text = strHeader + "-" + objWebClient.ResponseHeaders["strHeader"];
}
lblHTML.Text = lblHTML.Text + strRequestHTML;

Looking for the VB.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!

Download Project Source - Enter your Email to be emailed a link to download the Full Source Project used in this Tutorial!



100% SPAM FREE! We will never sell or rent your email address!



 
  Developer Resources







Server Intellect Rocks