【发布时间】:2018-06-25 14:14:32
【问题描述】:
我正在尝试使用 RSS 提要 URL 生成 XML 格式的数据。我得到了例外:
远程服务器返回错误 (400) 错误请求错误。
我使用的是 SSIS 包,我在控制流中创建了一个安全任务,我编写的脚本如下:
public bool DownloadFeed()
{
string user = "xxx";
string password = "pwd";
WebClient web = new WebClient();
System.Net.WebClient wc = new System.Net.WebClient();
wc.Credentials = new System.Net.NetworkCredential(user, password);
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 |
SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;
wc.DownloadFile(@"https://Entered RSS Feed URL here", @"H:\import\Test.xml");
return true;
}
【问题讨论】:
-
你试过没有 System.Net.ServicePointManager.SecurityProtocol
-
嗨。是的,我在得到之前尝试过请求被中止:无法创建 SSL/TLS 安全通道。错误。所以我在代码中添加了 System.Net.ServicePointManager.SecurityProtocol 行
-
非常感谢..它按预期工作