WebView2 log http traffic (inbound and outbound)

Viewed 445

As stated in the title i'm interested in the management (reading is sufficient by now) of the the incoming and outgoing data from the WebView2 istance user are using.

I'have try do add listener to WebMessageResourceRequested and WebMessageReceived but i have the sensation i missinterpreted their behaviour becasue they don't work as i expected (so is very likely that i am using that handler in a wrong way)

public partial class SimpleWebView2 : Form
{
    public SimpleWebView2 ()
    {
        InitializeComponent();

        this.Initialization();
    }

    private async void Initialization ()
    {
        await webView21.EnsureCoreWebView2Async();
        webView21.CoreWebView2.WebResourceRequested += new EventHandler<CoreWebView2WebResourceRequestedEventArgs>(this.webView21_WebMessageResourceRequested);
    }

    private void webView21_WebMessageResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
    {
         //does not fire
    }
}
1 Answers

A common solution is Fiddler. Just start it and you'll see the inbound and outbound traffic of any application, including the one that is using WebView2.

Related