Tuesday 13 November 2007

Request Failed: Unable to connect to remote server" error

When using the System.net.webclient class I recieved the error message "Request Failed: Unable to connect to remote server". The client had a proxy server so I thought maybe that was causing the problem and adding the proxy settings and it worked. And When I had a close look at I found out that If I added the proxy lines below, it still worked even though the proxy address is commented. I found this a bit wierd.

WebClient web = new WebClient();
WebProxy proxy = new WebProxy();
//proxy.Address = new Uri("*************:8080");
web.Proxy = proxy;

Even though I am creating an object of type Proxy I am not assigning the proxy address and it is working. But If comment the line //web.Proxy = proxy then it fails...I am not sure why.

No comments: