How to get HTTP request body with webview2

Viewed 894

I am trying to create a windows desktop application with browsing using webview2, using microdsoft's sample as a reference.

I want to get the Body data of the HTTP request sent by webview2 browsing, but I can't get it. (I was able to get the request header and request URL).

How can I get the body data?

namespace WPFSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            webView.NavigationStarting += EnsureHttps;
        }

        void EnsureHttps(object sender, CoreWebView2NavigationStartingEventArgs args)
        {
            String uri = args.Uri; //get request url
            CoreWebView2HttpRequestHeaders headers = args.RequestHeaders //get request headers
            //// how to get request body? ////
        }
    }
}
0 Answers
Related