Search code examples
c#webbrowser-controlfiddlerfiddlercore

Listen to a specific application using C# and FiddlerCore


I'am trying to integrate C# Web Browser control and Fiddler Core. I wan't to do this by letting Fiddler Core to listen to the Web Browser control without affecting any internet explorer or other internet browsers.

The diagram below should show what I want to achieve:

Internet Explorer -> Internet
Chrome -> Internet
Other Browsers -> Internet
Web Browser Control (Custom C# App) -> Fiddler Core -> Internet

The four instance below should run parallel without fiddler core interfering with other browsers. So if I wan't to change the response HTML in my Custom App, this will not affect the other browsers.

I've been searching on Google for a while now but I cannot see any concrete example to get me started.

Thank you in advance guys, any help would be greatly appreciated.


Solution

  • FiddlerCore exposes the calling process information in each session's X-ProcessInfo flag.

    By default, FiddlerCore will register as the system proxy and most applications will automatically route their traffic through it.

    If you want to capture traffic from only a single application, the steps are:

    1. Don't register as the system proxy when calling .Startup.
    2. The target application's proxy settings must be pointed at FiddlerCore's port.

    Now #1 is trivial, but #2 is harder, and depends entirely on what networking code the target application uses. You mentioned that the target application is a custom C# application hosting the .NET Web Browser control (which is just IE). If that's the case, and if the application is also hosting FiddlerCore, then you need only call

    Fiddler.URLMonInterop.SetProxyInProcess("127.0.0.1:8889", String.Empty);

    ...inside of your application.