我是Windows手机开发者,我想从HTTPS网站下载字符串,我使用
WebClient most_down_download = new WebClient();
most_down_download.DownloadStringCompleted += Most_down_download_DownloadStringCompleted;
most_down_download.DownloadStringAsync(new Uri(https_url));
但它不起作用。你能救我吗?
答案 0 :(得分:0)
也许是这样的?使用HTTP客户端代替Web客户端(8.1)
HttpClient http = new System.Net.Http.HttpClient();
HttpResponseMessage response = await http.GetAsync(https_url);
webresponse = await response.Content.ReadAsStringAsync();
答案 1 :(得分:0)
您需要生成Most_down_download_DownloadStringCompleted
事件处理程序,如下所示
void Most_down_download_DownloadStringCompleted(object sender,
System.Net.DownloadStringCompletedEventArgs e)
{
try
{
if (e.Error == null)
{
string response = e.Result.ToString();
}
}
catch (Exception ex)
{ }
}
在e.Result.ToString()
中你从网站上获取字符串