此(简化)C#/XAML UWP WebView应用在该应用程序后恢复大约90 sec后显示一个空白页。显示本地安全凸轮视频流网页时。在暂停该应用程序时,大约90秒后,它似乎超时,然后恢复WebView页面时,它是空白的。为了在下面提供示例代码以要显示的内容,我从Web搜索中随机选择了一个网站,并降落在http://www.porttampawebcam.com/上。我尝试过的几个YouTube和网络摄像头页没有像我本地的Web Cam Server一样重现计时问题。
一个按钮可用于手动刷新/重新加载页面,但是如何将其编码为...
a)每次恢复应用程序时都会迫使URL加载?b)检测到该页面已计时,然后根据需要重新加载?
我已经对此进行了一些研究(使用WebView Control& UWP应用程序生命周期),在GitHub上浏览了UWP应用程序,并在该应用程序的其他几个部分上取得了进展,但尚未弄清楚一个这两个点的工作解决方案。
应用程序是使用空白应用程序(通用窗口)模板在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();
}
}
我知道这有点晚,也许不是100%回答您的问题,但也许您可以尝试刷新这样的WebView内容:
await WebView.ClearTemporaryWebDataAsync();
yourWebView.Navigate(new Uri("https://www.yourUri.com"));