【问题标题】:How to download string from HTTPS website in windows phone 8如何在 Windows Phone 8 中从 HTTPS 网站下载字符串
【发布时间】:2015-11-20 19:43:48
【问题描述】:

我是 windows phone 开发者,我想从 HTTPS 网站下载字符串并使用

WebClient most_down_download = new WebClient();
most_down_download.DownloadStringCompleted += Most_down_download_DownloadStringCompleted;
most_down_download.DownloadStringAsync(new Uri(https_url));

但它不起作用。你能帮帮我吗?

【问题讨论】:

    标签: c# windows-phone-7 windows-phone-8 https httpwebrequest


    【解决方案1】:

    您需要生成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() 中,您正在从网站获取字符串

    【讨论】:

      【解决方案2】:

      也许是这样的?使用 HTTP Client 代替 Web Client (8.1)

      HttpClient http = new System.Net.Http.HttpClient();
      HttpResponseMessage response = await http.GetAsync(https_url);
      webresponse = await response.Content.ReadAsStringAsync();
      

      Reference here

      【讨论】:

      • 感谢您的支持,但仍然无法正常工作。
      • 不是错误信息,但是后面输出的不是完整的html文件
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-20
      相关资源
      最近更新 更多