Search code examples
c#windows-phone-7windows-phone-8httpshttpwebrequest

How to download string from HTTPS website in windows phone 8


I am windows phone developer, I want to download string from HTTPS web site and I use

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

but it is not working. Can you help me?


Solution

  • You need generate Most_down_download_DownloadStringCompleted event handler as below

    void Most_down_download_DownloadStringCompleted(object sender, 
                                  System.Net.DownloadStringCompletedEventArgs e)
    {
        try
        {
            if (e.Error == null)
            {
                string response = e.Result.ToString();
            }
        }
        catch (Exception ex)
        { }
    }
    

    And in e.Result.ToString() you are getting string from Web site