title: How to use WebClient.DownloadFile with digest authentication and a query string
body: <p>How do I use <code>WebClient.DownloadFile</code> with digest authentication and a query string?</p>
  
  <p>When I try to use it I get a 401 response.</p>
  
  <p>This is the Apache error log:</p>
  
  <pre><code>[Tue Jun 24 17:31:49 2014] [error] [client x.x.x.x] Digest: uri mismatch - &lt;/file-1.php&gt; does not match request-uri &lt;/file-1.php?since=1403587422&gt;
  </code></pre>
  
  <p>Here is how I try to download the file:</p>
  
  <pre><code>Uri uri = new Uri("http://example.com/file-1.php?since=1403587422");
  WebClient webClient = new WebClient();
  CredentialCache credentialCache = new CredentialCache();
  credentialCache.Add(
    new Uri(uri.GetLeftPart(UriPartial.Authority)),
    "Digest",
    new NetworkCredential("username", "password")
  );
  webClient.Credentials = credentialCache;
  webClient.DownloadFile(uri, file.OutputFile);
  </code></pre>