0

I want to call a website, that is generated depending on request and has an Url length of about 2200 chars.

When I call the donwload-Method with that Url using WebClient, the whole app crashes without any error message. Here is a sample of the link: http://tinyurl.com/bpp25za

How is it possible to download the content than?

Pamp
  • 69
  • 8
  • 1
    You may want to check this question too: http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url. 2200 seems to be a very long url. – ovolko Nov 07 '11 at 20:42
  • I got the data using the same Url `WebClient cln = new WebClient(); byte[] buf = cln.DownloadData("http://fahrplan.avv.de/.....");` – L.B Nov 07 '11 at 20:55
  • @L.B: I am using Silverlight/Windows Phone 7. MS does not provide this method in it... :( – Pamp Nov 07 '11 at 21:00
  • I have solved it using HtmlAgilityPack. Because I parse the page, it's even better, than just to get the string, because it creates a HtmlDocument Object. Now, the solution: HtmlWeb hb = new HtmlWeb(); hb.LoadCompleted += new EventHandler(hb_LoadCompleted); hb.LoadAsync(url); //where url = long url string Now I create method for Event handler: void hb_LoadCompleted(object sender, HtmlDocumentLoadCompleted e) { string k = e.Document.DocumentNode.InnerHtml; MessageBox.Show(k); } That's it :) – Pamp Nov 07 '11 at 21:22

1 Answers1

0

You could use WebBrowser instead:

    WebBrowser browser;

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        string url = @"your_really_long_url_here";

        browser = new WebBrowser();
        browser.Navigated += new EventHandler<NavigationEventArgs>(browser_Navigated);
        browser.Navigate(new Uri(url, UriKind.Absolute));
    }

    void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
    {
        string htmlContent = browser.SaveToString();
        System.Diagnostics.Debug.WriteLine(htmlContent);
    }
Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
  • even this solution is not complete. because of limitations from MS it's not possible to download the whole content. – Pamp Nov 14 '11 at 12:36