Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
 
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
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(VB)
WebClient to retrieve web page from URL in ASP.NET(VB)


ASP.NET Controls Tutorial

This tutorial will show you how to use WebClient to retrieve web page with VB.NET 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

Server Intellect offers Windows Hosting Dedicated Servers at affordable prices. I'm very pleased!

Add WebClient Control, a Click Button to the web page

Dim objWebClient As New WebClient()
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
lblHTML.Text = "<b>Request Header Information:</b>"
Dim strHeader As String
For Each strHeader In objWebClient.Headers
lblHTML.Text &= strHeader & "-" & objWebClient.Headers(strHeader) & "<br>"
Next

Dim objUTF8 As New UTF8Encoding()
Dim strRequestHTML As String

strRequestHTML = objUTF8.GetString(objWebClient.DownloadData(txtUrl.Text))

lblHTML.Text = "<p><b>Response Header Information:</b>"
For Each strHeader In objWebClient.ResponseHeaders
lblHTML.Text = strHeader & "-" & objWebClient.ResponseHeaders("strHeader")
Next
lblHTML.Text &= strRequestHTML
End Sub

Download the Full Working Version of this Project written with Visual Studio.NET VB.NET 2005 Here!

Looking for the C#.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!







 
  Developer Resources







Server Intellect Rocks