我遇到了问题。首先,这是我的代码:
HttpClient fond = new HttpClient();
using (var client = new HttpClient())
{
HttpClient.TransportSettings.Credentials = new System.Net.NetworkCredential("username", "pwd");
}
var reponse = await fond.GetStreamAsync("" + TitleNewsGrid.Text);
对我来说一切都还可以但是(抱歉这是我的第一个应用程序^^')当我编译时我发现了这个错误:
'System.Net.Http.HttpClient'不包含'TransportSettings'的定义
答案 0 :(得分:2)
试试这个
using (var handler = new HttpClientHandler())
{
handler.Credentials = new System.Net.NetworkCredential("username", "pwd");
using (var client = new HttpClient(handler){ })
{
// code
}
}
未经测试;)