WebView icon indicating copy to clipboard operation
WebView copied to clipboard

Reponse of OnBeforeResourceLoad is always null

Open WilliamQue opened this issue 9 months ago • 2 comments

I want to catch all responses after clicking the login button by BeforeResourceLoad enent of webview, and the responses are always null, so I can't get the resonses' bodies.

So, is the following a right way?

    private void WebView_OnBeforeResourceLoad(ResourceHandler rh) {
        if (rh.Url.Contains("user/info")) {
            if (rh.Response != null) {
                using (StreamReader reader = new StreamReader(rh.Response)){
                    string text = reader.ReadToEnd();
                    Console.WriteLine(text);
                }
            }
        }
    }

If you have a little more time , please help me how to get cookies when visiting an url. online help of webview2 is detailed, but this has too little to to be mastered easily.

WilliamQue avatar Jan 20 '25 13:01 WilliamQue