0
我创建了一个简单的现代UI应用程序,该应用程序在加载应用程序时显示WebView上本地主机站点的内容。当我调试它时,该应用完美运行。我已经用Visual Studio Remote Tools将它部署到另一台机器上,并且按预期工作。WebView应用程序显示空白页面
但是,当我在Windows商店中发布它,然后从那里安装应用程序时,页面为空白。商店中的应用程序名称为Locked Browser Lite。
我将不胜感激任何建议。
下面的代码:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace App3
{
/// <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();
this.Loaded += PageLoaded;
this.Unloaded += PageUnloaded;
wvMain.HorizontalAlignment = HorizontalAlignment.Stretch;
wvMain.VerticalAlignment = VerticalAlignment.Stretch;
//wvMain.Source = new Uri("http://localhost");
}
private void PageUnloaded(object sender, RoutedEventArgs e)
{
Window.Current.SizeChanged -= Window_SizeChanged;
}
private void PageLoaded(object sender, RoutedEventArgs e)
{
Window.Current.SizeChanged += Window_SizeChanged;
Uri targeturi = new Uri("http://localhost");
wvMain.Navigate(targeturi);
//wvMain.Refresh();
}
private void Window_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
wvMain.HorizontalAlignment = HorizontalAlignment.Stretch;
wvMain.VerticalAlignment = VerticalAlignment.Stretch;
}
private void btnReload_Click(object sender, RoutedEventArgs e)
{
PageLoaded(sender, e);
}
}
}
我有一个网页服务器在本地主机上提供Web应用程序。如果我使用Internet Explorer(城域和桌面),它工作正常。但该应用程序(通过Windows商店安装)显示一个空白页面。如果我通过Visual Studios Remote Tools部署应用程序,它可以正常工作。我猜测Windows应用商店对应用增加了某种限制? –
是的,主要是因为商店 –
应用程序被沙箱化,无法连接到本地主机。但是,有这个方便的工具:https://loopback.codeplex.com/ – AyCe