Skip to content

Reponse of OnBeforeResourceLoad is always null #378

@WilliamQue

Description

@WilliamQue

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions