title: 407 Proxy Authentication Required
body: <p>I am working on a website, in which I am retrieving XML data from an external URL, using the following code </p>
  
  <pre><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);
  </code></pre>
  
  <p>This code is working fine on my development PC (Windows XP with .Net 3.5)</p>
  
  <p>But when I deploy this code to IIS (Both at Windows XP and at Windows Server 2003) it's giving me following error</p>
  
  <p>"The remote server returned an error: (407) Proxy Authentication Required." </p>
  
  <p>Sometimes it gives me </p>
  
  <p>"The remote server returned an error: (502) Bad Gateway."</p>
  
  <p>Following code is from my web.config</p>
  
  <pre><code>&lt;system.net&gt;
      &lt;defaultProxy&gt;
        &lt;proxy  usesystemdefault="False" proxyaddress ="http://172.16.12.12:8080" bypassonlocal ="True" /&gt;
      &lt;/defaultProxy&gt;
    &lt;/system.net&gt; 
  </code></pre>
  
  <p>Please help me ?</p>
  
  <p><strong>[Edit]</strong>
  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."</p>
  
  <p>But when i run website from Microsoft Devlopment server, it is running fine</p>