Unable to display 127.0.0.1 page in WebView under WinForms .net application

Viewed 1155

I am trying to display a web application, that is running on a local server under 127.0.0.1:8000, as a desktop application.

To achieve this I am writing a WinForms application that is hosting a webview. The Package is Microsoft.Toolkit.Win32.UI.Controls.WinForms.WebView

The webview is properly working when displaying Google. After setting the IsPrivateNetworkClientServerCapabilityEnabled property to true it was also working when accessing my router with the URI http://192.168.178.1:80. But when trying to access http://127.0.0.1:8000 the webview isn't displaying anything, although Edge(which the webview is based on) is able to.

How can I make the webview display a page that is located on my computer?

1 Answers

The problem was that loopback is forbidden, a solution for development is to add a loopback exemption for the webview with the following command: checknetisolation LoopbackExempt -a -n=Microsoft.Win32WebViewHost_cw5n1h2txyewy See https://msdn.microsoft.com/en-us/library/windows/apps/hh780593.aspx for more info.

You can find the app ID in the registry under HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer

Related