1

This (simplified) c# / XAML UWP Webview app displays a blank page after the app is resumed after about 90+ sec. when displaying a local security cam video stream webpage. It appears to timeout after about 90 sec while the app is being suspended and then upon resuming the webview page is blank. To give the sample code below something to display, I randomly picked a site from a web search and landed on http://www.porttampawebcam.com/. The few youtube and webcam pages I've tried didn't reproduce the issue of timing out like my local web cam server does after a min. or so of inactivity.

A button can be used to manually refresh / reload the page, but how can it be coded to ...

A) Force the url to load every time the app gets resumed? B) Detect that the page has timed out and then reload as needed?

I've done a bit of research on this (using the webview control & UWP application lifecyles), browsed uwp apps on GitHub, and have made progress on several other parts of the app, but have yet to figure out a working solution on these two points.

App was built using the Blank App (Universal Windows) template in Visual Studio 2015.

XAML:

Mainpage.xaml

<Page
    x:Class="WVMinimal.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="*" ></RowDefinition>
        <RowDefinition Height="auto" ></RowDefinition>

    </Grid.RowDefinitions>
    <WebView Name="WV" Source="http://www.porttampawebcam.com"/>
    </Grid>
</Page>

c#:

Mainpage.xaml.cs


using Windows.UI.Xaml.Controls;

    // The Blank Page item template is documented at     https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

    namespace UWPWebviewTest5
    {
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {

        public MainPage()
        {
            this.InitializeComponent();

        }


}
CFDEV
  • 11
  • 1
  • 5

1 Answers1

0

I know it's a bit late and maybe not 100% answering your question but maybe you could try to refresh the WebView content like this:

await WebView.ClearTemporaryWebDataAsync();
yourWebView.Navigate(new Uri("https://www.yourUri.com"));
Pedro del Sol
  • 2,840
  • 9
  • 39
  • 52
Paul S.
  • 1
  • 1
  • I was actually able to get the webview content to reload after 30+ second resuming periods (first part of my question) by using the following in the mainpage.cs file "private void CoreWindow_VisibilityChanged(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.VisibilityChangedEventArgs args) { if (App.IsFromResume) WV.Navigate(new Uri("url")); } " along with some changes to the app.cs file referenced in previous postings. The second part of my question is still unresolved and or I haven't figured out a solution to yet. – CFDEV Jul 06 '17 at 21:07
  • The second part of my question is still unresolved and or I haven't figured out (if a practical UWP solution is feasible) yet. – CFDEV Jul 06 '17 at 21:17
  • Sorry for the delay in responding as I intended to split my question up since the first part was actually resolved and then create a separate question for the second part. I'm certainly open to any suggestions that anyone may have. Thanks – CFDEV Jul 06 '17 at 21:25