MicrosoftEdge / WebView2Samples

Microsoft Edge WebView2 samples
830 stars 460 forks source link

_webView2.CoreWebView2.WebResourceResponseReceived is not invoked #164

Open WenningQiu opened 1 year ago

WenningQiu commented 1 year ago

My application works fine on my laptop (Windows 10).

When the application runs on my dev VM (Windows Server 2016), the interaction with the Web server and rendering of web pages are all good, and the request and response messages exchanged with the Web server are captured by Fiddler; however, _webView2.CoreWebView2.WebResourceResponseReceived is not invoked.

The version of "Microsoft.Web.WebView2" package is "1.0.1418.22". The runtime version is the same on both machines: image

        private void CoreWebView2Ready(object sender, EventArgs e)
        {
            _webView2.CoreWebView2.WebResourceRequested += WebResourceRequested;
            _webView2.CoreWebView2.WebResourceResponseReceived += ResponseReceived;
            _webView2.CoreWebView2.ClientCertificateRequested += ClientCertificateRequested;

            _webView2.CoreWebView2.Settings.AreHostObjectsAllowed = false;
            _webView2.CoreWebView2.Settings.IsWebMessageEnabled = false;
            _webView2.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;

            _webView2.Source = new Uri(SsoEndpointUrl);
        }
WenningQiu commented 1 year ago

The application was deployed to my dev VM using MSI which was missing a dependency DLL. WebView2 started to work normally once the missing DLL was added.

It is weird how a missing DLL could impact WebView2 behavior. The missing DLL, which was written by me, is purely for the application logic and is completely irrelevant to WebView2.