cspaceman
unread,May 6, 2009, 5:44:25 AM5/6/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,
Pretty new to c# / .NET - apologies in advance if this is obvious or
trivial.
I'm trying to save webpages (testcode with
google.com) using the code
shown below (mostly cobbled together from various places). On the
line
strm = Client.OpenRead("
http://www.google.com");
An error is raised:
"An unhandled exception of type 'System.Net.WebException' occurred in
System.dll
Additional information: Unable to connect to the remote server"
Could anyone shine some light on why this mght be happening. I'm
working behind a corporate firewall in case that makes any
difference.
Full code:
public Form1()
{
InitializeComponent();
string line;
Stream strm;
WebClient Client;
StreamReader sr;
WebProxy proxy;
proxy = new WebProxy("**.***.***.***:8080");
proxy.Credentials = CredentialCache.DefaultCredentials;
proxy.Credentials = new NetworkCredential(<userID>,
<myPassword>);
GlobalProxySelection.Select = proxy;
Client = new WebClient();
Client.Headers.Add("user-agent", "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
strm = Client.OpenRead("
http://www.google.com");
sr = new StreamReader(strm);
do
{
line = sr.ReadLine();
listBox1.Items.Add(line);
}
while (line != null);
strm.Close();
}
Many thanks,
Chris