how to capture http request using Fiddlercore in C#?

烈酒焚心 提交于 2019-12-02 05:46:44
  1. You should set Selenium to go through the FiddlerCore proxy, this is how you do it:

    var seleniumProxy = new Proxy { HttpProxy = "localhost:8878", SslProxy = "localhost:8878" };
    var profile = new FirefoxProfile();
    profile.SetProxyPreferences(seleniumProxy);
    var slenium = new FirefoxDriver(profile);
    
  2. Advice, you can set some more flags when starting the FiddlerCore in order to save you some troubleshooting in the future:

    const FiddlerCoreStartupFlags fiddlerStartUpFlags = FiddlerCoreStartupFlags.DecryptSSL & FiddlerCoreStartupFlags.AllowRemoteClients & FiddlerCoreStartupFlags.CaptureFTP & FiddlerCoreStartupFlags.ChainToUpstreamGateway & FiddlerCoreStartupFlags.MonitorAllConnections & FiddlerCoreStartupFlags.CaptureLocalhostTraffic;
    
    FiddlerApplication.Startup(8877, fiddlerStartUpFlags);
    
  3. Since you are probably using FiddlerCore + Selenium for testing, you will need to add some other stuff:

When a test finish, execute this -

    FiddlerApplication.oProxy.PurgeServerPipePool();//Run this between tests to make sure the new test will start "clean"

Before calling FiddlerApplication.Startup(8877, fiddlerStartUpFlags);, execute these -

    FiddlerApplication.Prefs.SetStringPref("fiddler.config.path.makecert", @"d:\..\Makecert.exe");//To define the MakeCert.exe path manually.
    FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);//Abort session when client abort
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!