如何将 WebClient.DownloadFile
与摘要式身份验证和查询字符串一起使用?
当我尝试使用它时,我收到了 401 响应。
这是 Apache 错误日志:
[Tue Jun 24 17:31:49 2014] [error] [client x.x.x.x] Digest: uri mismatch - </file-1.php> does not match request-uri </file-1.php?since=1403587422>
以下是我尝试下载文件的方式:
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);
最佳答案
WebClient webCl = new WebClient();
webCl.Credentials = new NetworkCredential("username", "Password");
webCl.DownloadFile(file download URL, fil save path with FileName);
关于c# - 如何使用带有摘要式身份验证和查询字符串的 WebClient.DownloadFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24399527/