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