407 Proxy Authentication Required

Posted by Hemant Kothiyal on Stack Overflow See other posts from Stack Overflow or by Hemant Kothiyal
Published on 2009-10-06T09:35:36Z Indexed on 2010/03/26 4:03 UTC
Read the original article Hit count: 955

Filed under:
|

I am working on a website, in which I am retrieving XML data from an external URL, using the following code

WebRequest req = WebRequest.Create("External server url");
req.Proxy = new System.Net.WebProxy("proxyUrl:8080", true);
req.Proxy.Credentials = CredentialCache.DefaultCredentials;
WebResponse resp = req.GetResponse();
StreamReader textReader = new StreamReader(resp.GetResponseStream());
XmlTextReader xmlReader = new XmlTextReader(textReader);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);

This code is working fine on my development PC (Windows XP with .Net 3.5)

But when I deploy this code to IIS (Both at Windows XP and at Windows Server 2003) it's giving me following error

"The remote server returned an error: (407) Proxy Authentication Required."

Sometimes it gives me

"The remote server returned an error: (502) Bad Gateway."

Following code is from my web.config

<system.net>
    <defaultProxy>
      <proxy  usesystemdefault="False" proxyaddress ="http://172.16.12.12:8080" bypassonlocal ="True" />
    </defaultProxy>
  </system.net>

Please help me ?

[Edit] Even when i run the website for devlopment PC but through IIS it gives me error "The remote server returned an error: (407) Proxy Authentication Required."

But when i run website from Microsoft Devlopment server, it is running fine

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about proxy