locked
file downloading in c#/xaml metro apps in WebView control RRS feed

  • Question

  • I am developing a metro style app. I am using WebView control for accessing the website. Now when I want to download something, I can't get popup for saving it, what I get is just blank page.

    I have checked this solution on this forum. So is there any workaround for downloading files from my metro app without opening IE ? Basically my aim is to download file within the environment of my app.

    Wednesday, July 25, 2012 12:58 PM

Answers

  • It's going to be a little bit complicated...  you'll have to download the content of your page first, get the string, add some script to handle navigation events, and then use NavigateToString to put it into your webview.  The script will pass the URL to your C# code and then you can do whatever you want with it.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    • Marked as answer by Min ZhuMember Saturday, August 11, 2012 7:35 AM
    Thursday, July 26, 2012 6:30 PM
    Moderator

All replies

  • Do you have control of the website being accessed?  If so, I would recommend that you pass the URL of the download to script and then read it into your C# code, download it using C#.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Wednesday, July 25, 2012 2:58 PM
    Moderator
  • the URL for downloading file is dynamic i.e download link is generate at runtime, so I can't pass it into my C# code.
    Is there any way for capturing links while click on any webpage ? Suppose I've open a page with 5 hyperlinks. So when I click on any hyperlink I will get its URL. Is there any way to do this ?

    P.S. for static URL I thought to open IE and then in that downloading will be done.

    • Edited by Xyroid Thursday, July 26, 2012 7:09 AM
    Thursday, July 26, 2012 4:55 AM
  • It's going to be a little bit complicated...  you'll have to download the content of your page first, get the string, add some script to handle navigation events, and then use NavigateToString to put it into your webview.  The script will pass the URL to your C# code and then you can do whatever you want with it.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    • Marked as answer by Min ZhuMember Saturday, August 11, 2012 7:35 AM
    Thursday, July 26, 2012 6:30 PM
    Moderator