Hi The code below works fine to instruct the system not to use a proxy and to not auto detect one, which causes a delay without the code. However while on a network with a proxy I just get the underlying connection is closed! So four questions:
- Am I specifying the proxy correctly?
- If so how do I tell it to use default proxy credentials?
- Should the used want to specify credentials how are they set?
- How do I set it back to the original state?
if (!Properties.Settings.Default.UseProxyServer){
//set the system not to use a proxy server
//saves the delay seen when browser set to auto detect proxy and not proxy
//is used. This works well!!
WebRequest.DefaultWebProxy = new WebProxy();
}
else{
WebRequest.DefaultWebProxy =
new WebProxy(proxyServerAddress, proxyServerPort);
//proxyServerPort is an int.
//How do I add default credentials??
}
WebClient client = new WebClient();
//specify an encoding for uploading.
client.Encoding = System.Text.Encoding.ASCII;
// Upload the data.
var myReply = client.UploadValues(addressURL, data);
I need to this in code not in the app.config.
Thanks