简体   繁体   中英

UWP Webview Navigate to Localhost Page (404 not found)

I am trying to set up a local hosted page for webview prototype testing. However, when trying to let webview navigate to this page, it keeps failing with 404 (not found) error status.

Windows::UI::Xaml::Controls::WebView^ m_webview; // this is how m_webview is defined
String^ launchUri = L"http://localhost:8000/index-native.html";
m_webview->Navigate(ref new Uri(launchUri));

notice that I tried to replace with machine name or an real ip address but neither approach worked. The hosted page itself can be visited by machines within the same network using the uri with machine name embedded.

What's more interesting is that if I change the launchUri to " http://microsoft.com " this thing will work! I don't see any difference between my local hosted web page and the microsoft page from navigation's perspective.

Could anyone please help? Thanks!

Gaurang Dave's suggestion is correct. You would need to enable the 'Private Networks(Client & Server)' capability.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM