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
{{ message }}
Repository navigation
Allow cancelling/overriding web resources in NativeWebView WebResourceRequested event #53
Is your feature request related to a problem? Please describe.
Currently, WebResourceRequestedEventArgs only contains information about the requested web resource with no way to interact with the requested resource. It would be useful to allow a way to cancel the requested web resource from within WebResourceRequested event.
Describe the solution you'd like
I would like to see the WebResourceRequestedEventArgs have a way to cancel the requested resource (something like e.Cancel = true), similar to the WebViewNavigationStartingEventArgs which allows for cancelling of navigation.
Another options could be to even allow to override/force a response for the requested web resource instead of simply cancelling it (and something like setting a blank response would be equivalent to cancelling it).
Yes, I would also like to expand on this... Add full WebResourceRequested interception and response override support.
Since NativeWebView currently exposes WebResourceRequested but applications can't cancel a request or override response.
Please consider extending the API to support full request interception, including:
Canceling/blocking requests before they reach the network.
Redirecting requests.
Modifying request headers.
Providing a custom response without contacting the network.
Modifying response headers.
Replacing response content/body.
Returning custom status codes.
Optionally streaming response content.
This would enable advanced integrations such as adblock-rust (i could release my c# bindings), custom caching layers, offline resource handling, request rewriting, proxying, content transformation, security filtering, and application-specific virtual resources.
The browser would receive this response as if it came from the requested URL, without necessarily performing the original network request.
Example: adblock-rust integration
A filtering engine could inspect each request:
webView.WebResourceRequested+=(_,e)=>{varresult=adblockEngine.Check(e.Request.Url,e.Request.Method,e.Request.Headers);if(result.ShouldBlock){e.Response=WebResourceResponse.Block();return;}if(result.ReplacementContentis not null){e.Response=newWebResourceResponse{StatusCode=200,Headers={["Content-Type"]=result.ContentType},Content=result.ReplacementContent};}};
Example: request/response transformation
More advanced users could implement transformations such as:
Ideally, this should be a platform-independent abstraction over the underlying engines (WebView2, WKWebView, WebKitGTK/WPE, etc.), while exposing only capabilities that can be implemented consistently.
At minimum, applications should be able to make an explicit decision for each intercepted request:
Allow normally
Block
Redirect
Replace response
This would make NativeWebView significantly more useful for applications requiring embedded-browser filtering, offline resources, custom protocols, response rewriting, caching, and other advanced networking scenarios.
Activity
Cheatoid commentedon Sep 2, 2026
Yes, I would also like to expand on this... Add full
WebResourceRequestedinterception and response override support.Since
NativeWebViewcurrently exposesWebResourceRequestedbut applications can't cancel a request or override response.Please consider extending the API to support full request interception, including:
This would enable advanced integrations such as adblock-rust (i could release my c# bindings), custom caching layers, offline resource handling, request rewriting, proxying, content transformation, security filtering, and application-specific virtual resources.
Example: blocking a request
Example: replacing the response
For example, an application could intercept a JavaScript resource and provide its own content:
The browser would receive this response as if it came from the requested URL, without necessarily performing the original network request.
Example: adblock-rust integration
A filtering engine could inspect each request:
Example: request/response transformation
More advanced users could implement transformations such as:
For larger resources, the API could ideally support a stream-based response rather than requiring the entire body to be held in memory:
Suggested API characteristics
Ideally, this should be a platform-independent abstraction over the underlying engines (WebView2, WKWebView, WebKitGTK/WPE, etc.), while exposing only capabilities that can be implemented consistently.
At minimum, applications should be able to make an explicit decision for each intercepted request:
This would make
NativeWebViewsignificantly more useful for applications requiring embedded-browser filtering, offline resources, custom protocols, response rewriting, caching, and other advanced networking scenarios.