WebResourceRequested on different resources is invoked after navigating to a different page
While navigating back and forth between different pages with the WebView, sometimes WebResourceRequested is called with resource requests that are from a previous page.
If such calls can't be cancelled or filtered out by the API, I suggest at least adding the relevant NavigationId to the CoreWebView2WebResourceRequestedEventArgs class (similar to the classes CoreWebView2ContentLoadingEventArgs, CoreWebView2DOMContentLoadedEventArgs, etc.) so that resource requests can be distinguishable to their corresponding navigation source.
Hi @nirbil , I'd expect that some of the resources are refreshed on back-forward navigations and correspondingly additional WebResourceRequested events will fire and if navigating back/forward too rapidly, the app could receive events for resource requests even though the WebView2 navigated away from the page with that resource. We will look into being able to map the WebResourceRequest to a given navigation ID as a feature request. For reference, what is the specific scenario you are trying to achieve here?
If I want to intercept all the resources of a specific page I couldn't do that because I can't distinguish between resources of different page loads.
Hi @nirbil, could you please tell a bit more about what kind of application you're building, and the particular scenario you are trying to accomplish here? It would be particularly beneficial if you could share some example use cases. Thank you!
Was using it to identify if a certain page is accessing insecure resources. I don't have a need for this anymore, but it feels like an inconsistent behavior. I'd at least expect to get a navigationId, similar to other API calls.