You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
BeforeResourceLoad is an event triggered before the actual request is made to the target, thats why you see a null Response.
AFAIK you can't get the responses once you let them flow to CEF (the webview core).
In order to do that you need to perform the requests by yourself (eg: using a plain HttpClient) in the BeforeResourceLoad, copy the headers and request payload into the request and then waiting for the response. Once you get the response from the HttpClient you can read and manipulate it and then pass it to the webview using the RespondWith method of the event object.
I just want to get some json format responses when loging in a website, it's easy to submit username and password or scan QR code to log in, but not easy to prepare the payload with incomprehensible fields。
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?
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.
The text was updated successfully, but these errors were encountered: