Click to See Complete Forum and Search --> : Webclient: The remote server returned an error: (407) Proxy Authentication Required.


dannystommen
February 11th, 2010, 03:42 AM
Hi all,

I have the following existing code (already in production for a few months)

using (System.Net.WebClient client = new System.Net.WebClient()) {
client.Credentials = new System.Net.NetworkCredential("user", "pass", "domain");

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(client.OpenRead("http://url.com/doc.xml"));
...
}

Since yesterday, I recieve the following exception on client.OpenRead: Webclient: The remote server returned an error: (407) Proxy Authentication Required.

Now I changed the code to

using (System.Net.WebClient client = new System.Net.WebClient()) {
client.Credentials = new System.Net.NetworkCredential("user", "pass", "domain");
client.Proxy = new System.Net.WebProxy() {
Credentials = new System.Net.NetworkCredential("user", "pass", "domain")
};
}

Now it is working again, but this would mean that everyone here needs to reinstall the application (it's a winform app).

The folder where the XML file is located, is secured with Windows Authentication. Even if I enable Anonymous Authentication in IIS, I get the same exception.

Is there any way to prevent this error from happening without the code change, so that the users do not need to reinstall the app?

dannystommen
February 11th, 2010, 08:59 AM
Really strange, the exception disappeared... The network administrator here is not aware of any changes made that possibily could have caused this error.

Anyone here an idea?