title: System.Data.DataSet.ReadXml - Proxy Authentication Required
body: <p>I have a piece of old code (a single .aspx file) that I need to get through a proxy.  This code used to work, but now the company have tightened up on security.</p>
  
  <p>The offending line of code is:</p>
  
  <pre><code>dataSet.ReadXml(url);
  </code></pre>
  
  <p>The url is https.</p>
  
  <p>It is running on .NET version 2.0 - this cannot be upgraded.
  I cannot change the web.config file.</p>
  
  <p>What do I need to add to the .aspx file to get it to work?
  The error I am getting is:</p>
  
  <pre><code>The remote server returned an error: (407) Proxy Authentication Required.
  </code></pre>
  
  <p>There is no "connecting to the web" code in the script.</p>
  
  <p><em>EDIT</em></p>
  
  <p>Based on Dan's comment, I have tried this:</p>
  
  <pre><code>HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  IWebProxy proxy = request.Proxy;                    
  WebProxy myProxy = new WebProxy();
  Uri newUri = new Uri("http://10.79.30.190:8080");
  // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
  myProxy.Address = newUri;
  // Create a NetworkCredential object and associate it with the 
  // Proxy property of request object.
  myProxy.Credentials = new NetworkCredential("username", "password");
  request.Proxy = myProxy;
  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
  
  System.Data.DataSet dataSet = new System.Data.DataSet();
  dataSet.ReadXml(responseString);
  </code></pre>
  
  <p>but am still getting the same error</p>
  
  <p><em>EDIT</em></p>
  
  <p>Another attempt:</p>
  
  <pre><code>HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  IWebProxy proxy = request.Proxy;                    
  WebProxy myProxy = new WebProxy();
  Uri newUri = new Uri("http://10.79.30.190:8080");
  // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set.
  myProxy.Address = newUri;
  // Create a NetworkCredential object and associate it with the 
  // Proxy property of request object.
  myProxy.Credentials = new NetworkCredential("username", "password");
  request.Proxy = myProxy;
  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  
  System.Data.DataSet dataSet = new System.Data.DataSet();
  dataSet.ReadXml(new StreamReader(response.GetResponseStream()));
  </code></pre>
  
  <p>but am still getting the same error</p>