Search code examples
c#httpresponsefiddlerintercept

fiddlercore creating an auto response from file using C# (code wont work)


I am trying to intercept a http request to a website. I used the fiddler application, and found the response from the site and saved the entire response body as a file (txt). And the fiddler application allows me to select that file as an auto response. Doing this works great.

How ever when I try to use fiddlercore it does not seem to work, and I am not sure why. I have tried placing message boxes in the events so I know when they fire, and they do fire. How ever I can not seem to load the same response file as I did with the main application. here is my code. Everything runs without exceptions...just I am still getting the response from the server not from the file. I am sure I am only a line or two off.

        FiddlerApplication.BeforeRequest += delegate(Session session)
        {
            if (session.uriContains(@"http://www.website.com/request.php"))
            {
                session.bBufferResponse = true;
            }
        };

        FiddlerApplication.BeforeResponse += delegate(Session session)
        {
                session.utilDecodeResponse();
                session.LoadResponseFromFile("website.txt");
        };

Thanks!


Solution

  • Turns out my problem is that I was not starting it properly, it was just not using the API right.