我曾经在一个窗口服务运行下面的代码:Web客户端生成(401)未经授权错误
WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("me", "12345", "evilcorp.com");
webClient.DownloadFile(downloadUrl, filePath);
每一次,我得到下面的异常
{"The remote server returned an error: (401) Unauthorized."}
用下面的内部异常:
{"The function requested is not supported"}
我知道肯定的凭据是有效的,事实上,如果我去downloadUrl在我的网页眉毛呃并把我的凭据作为evilcorp.com \我的密码12345,它下载罚款。
虽然有点奇怪,但如果我用12345指定我的凭证为[email protected],它似乎失败。
有没有格式化凭证的方法?
你有没有想过这个问题的解决方案(代码)? – Crash893 2012-02-16 04:29:55