I have a WPF application with a WebBrowser control.
I’d like to intercept and trace the http request issued by the browser control.
I don’t want to modify the content. I only want to perform some rules when loaded urls are matching a specific pattern. Especially, I have some ajax call that are returning data that populate the web controls.
I want to capture this data to act also in the container application. Is it possible? How?
The conrtol have a LoadCompleted event, but it’s only fired for the uri specifid in the Source property, not subressourceS.
As answered in the duplicate, here is the solution :
I have been able to solve such issue.
You will need some 3rd party assemblies :
The idea, as you guess, is to create an in-memory proxy server, and redirect your web browser control to this proxy.
Then, FiddlerCore publishes some events where you can analyse the request/response, especially the body.
As it acts a proxy, all communications, including Ajax calls, Flash calls, etc, are routed by the proxy.
If it can help, a small code that help me to prototype this behavior:
App.cs :
MainWindow.xaml :
And finally, MainWindow.xaml.cs :
You will have to add some plumbing to this application, in order to route and analyse the requestion from the app to the business class, but that’s beyond the scope of this question.