DotNet Tutorials

Server Intellect

 WebClient to retrieve web page from URL in ASP.NET(VB)

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

Add WebClient Control, a Click Button to the web page

Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.

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



Looking for the C#.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!
 
123 ASP

411 ASP

Dot Net Freaks

Server Intellect