Hello,
I am trying to download web data into my current application. Failing
many attempts I tried to run the sample from the MS Help files with no
luck. If I create a new solution and put the sample code on a button
then it works. However, when do the same on a new form in my existing
solution then I get following error. Could there be some global
settings in my application that are causing problems?
Thanks in advance,
-Dave
Error:
-----------------------------------------------
An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: An exception occurred during a WebClient
request.
Sample Code:
-----------------------------------------------
Dim remoteUrl As String = "http://www.msn.com"
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
' Download the home page data.
Console.WriteLine(("Downloading " + remoteUrl))
' Downloads the Web resource and saves it into a data buffer.
' !!!!!!!!!! THIS LINE CAUSES THE ERROR !!!!!!!!!!!!!!!
Dim myDatabuffer As Byte() = myWebClient.DownloadData(remoteUrl)
' Display the downloaded data.
Dim download As String =
System.Text.Encoding.ASCII.GetString(myDatabuffer)
Console.WriteLine(download)
Console.WriteLine("Download successful.")