如何在windowsphone 8中从HTTPS网站下载字符串
本文关键字:HTTPS 网站 下载 字符串 中从 windowsphone | 更新日期: 2023-09-27 18:22:49
我是windows手机开发人员,我想从HTTPS网站下载字符串,我使用
WebClient most_down_download = new WebClient();
most_down_download.DownloadStringCompleted += Most_down_download_DownloadStringCompleted;
most_down_download.DownloadStringAsync(new Uri(https_url));
但它不起作用。你能帮我吗?
您需要生成如下所示的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()
中,您将从网站中获取字符串
也许是这样的?使用HTTP客户端而不是web客户端(8.1)
HttpClient http = new System.Net.Http.HttpClient();
HttpResponseMessage response = await http.GetAsync(https_url);
webresponse = await response.Content.ReadAsStringAsync();
此处参考