Microsoft.Toolkit.Win32 icon indicating copy to clipboard operation
Microsoft.Toolkit.Win32 copied to clipboard

Cannot navigate to localhost

Open scegg opened this issue 5 years ago • 2 comments

I'm submitting a...

  • Bug report (I searched for similar issues and did not find one)

Current behavior

While navigating to localhost site with IsPrivateNetworkClientServerCapabilityEnabled set to true, nothing happened, blank displaying with no DOMContentLoaded raised.

It's similar like set IsPrivateNetworkClientServerCapabilityEnabled to true between BeginInit and EndInit in Winform. Reported here.

Expected behavior

Works like Edge or other web browsers.

Minimal reproduction of the problem with instructions

        webView1.Navigate("http://localhost/test/");

Environment

Nuget Package(s): Microsoft.Toolkit.Wpf.UI.Controls.WebView 5.1.1

Package Version(s):

Windows 10 Build Number:

  • [x] Insider Build (build number: 18912)

App min and target version:

  • [x] Insider Build (18912)

Device form factor:

  • [x] Desktop

Visual Studio

  • [x] 2019

NetFx 4.8

Codes for test: EdgeTest.zip

scegg avatar Jun 11 '19 03:06 scegg

As a workaround you can execute this command as an administrator. This will allow EdgeHTML to access localhost URLs.

checknetisolation LoopbackExempt -a -n="Microsoft.Win32WebViewHost_cw5n1h2txyewy"

The program needs to be run only once. It is a clutch, but I so far have not found a better solution.

r0x0r avatar Jun 22 '19 09:06 r0x0r

For completeness, to make your app do it on its own call this method when your app starts:

private static void AllowLoopBack()
{
    if (runOnce)
    {
        return;
    }

    runOnce = true;

    new Process
    {
        StartInfo = new ProcessStartInfo
        {
            WindowStyle = ProcessWindowStyle.Hidden,
            UseShellExecute = true,
            FileName = "cmd.exe",
            Arguments =
                "/C checknetisolation LoopbackExempt -a -n=\"Microsoft.Win32WebViewHost_cw5n1h2txyewy\"",
            Verb = "runas"
        }
    }.Start();
}

bitbonk avatar Mar 19 '20 22:03 bitbonk