I have written a code to hit a particular URL and download data using a WebClient, and have set a proxy which I have purchased from MyPrivateProxies.net to this webclient with credentials and other needed parameters through which it hits the mentioned URL.
But I get this exception every time at the last line.
System.Net.WebException: Unable to connect to the remote server System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
below is my snippet of code:
WebClient client = new WebClient();
WebProxy webProxy = new WebProxy("my_proxy_with_port");
NetworkCredential netcredit = new NetworkCredential(username, password, domain);
client.Credentials = netcredit;
webProxy.Credentials = netcredit;
webProxy.UseDefaultCredentials = false;
webProxy.BypassProxyOnLocal = false;
client.Proxy = webProxy;
client.Encoding = Encoding.UTF8;
String strURL = "url_to_be_hit";
String jsonString = client.DownloadString(strURL);
Do I need some other settings on my windows 7 system or any config changes in app.config
?
Are there other configuration for a console app to use proxies?