Tirolel
Tirolel

Reputation: 928

Download with Webview Windows 8

I'm really stuck with an issue. I would like to download a PDF/ZIP formatted file from webview but I can't find any solution/tutorial on the internet, I tried to look webview property class.
i have a webview:

WebView x:Name="webviewIntranet" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

and my method:

public IntranetPage()
{
   webviewIntranet.Navigate(new Uri("http://www.testme.com"));
           this.InitializeComponent();
}

I'm able to show the webpage content but nothing happens when a try to download/click to download some files.

Upvotes: 4

Views: 1703

Answers (3)

marmots
marmots

Reputation: 101

First of all some reading about what's new in WebView control http://blogs.windows.com/windows/b/appbuilder/archive/2013/07/17/what-s-new-in-webview-in-windows-8-1.aspx

as you can see, WebView hanldes different browser events: It doesn't support showing nothing else than webpages, but WebView.UnviewableContentIdentified event is fired for them http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.webview.unviewablecontentidentified.aspx

Then you can use file association to throw it to the OS (or do what you need with the file throught the uri... i hope)

void webView1_UnviewableContentIdentified(WebView sender, 
    WebViewUnviewableContentIdentifiedEventArgs args)
{
    Windows.Foundation.IAsyncOperation<bool> b = 
    Windows.System.Launcher.LaunchUriAsync(args.Uri);
}

Upvotes: 3

Paul Michaels
Paul Michaels

Reputation: 16705

I think you can do this, but there's quite a bit of manual intervention. Using something like the BackgroundDownloader you can download a file that you have the URI for. Is you want to also intercept web view navigation, then there's a few workarounds for that; for example: here

Upvotes: 0

Farhan Ghumra
Farhan Ghumra

Reputation: 15296

WebView can't download file. Microsoft has tried not to be WebView, a replacement of IE browser. See the answer from MSDN forum.

Upvotes: 1

Related Questions