FIddlerCore - Manipulating Response to Web Browser not Working

3 posts, 0 answers
  1. kris
    kris avatar
    8 posts
    Member since:
    Nov 2015

    Posted 01 Nov 2015 Link to this post

    Thanks for FiddlerCore and the quick responses to questions on this forum.
    I'm trying to intercept a webpage response, change some html, and have it display my change in the browser:

    private void FiddlerApplication_BeforeResponse(Session oSession)


    oSession.bBufferResponse = true;



    oSession.utilReplaceInResponse("TEXT-TO-REPLACE", "NEW-TEXT");


    I should note that I'm using Windows 10, which I'm not sure if it makes any difference.  I know that the oSession's ResponseBody text is updated when I use this code, however it seems like it doesn't get passed on to the browser from this point.  Am I missing something?  I've even tried utilSetResponseBody(updatedBodyText), however this doesn't seem to update the returned page either.  Any thoughts or help would be greatly appreciated.




















  2. kris
    kris avatar
    8 posts
    Member since:
    Nov 2015

    Posted 01 Nov 2015 Link to this post

    By the way, sorry for the yucky post -- had no idea it would show up like that.  Should have looked at 'Formatting options.'  Anyways, I ended up finding the solution to my problem from stumbling upon another forum post.  It turns out that I was setting oSession.bBufferResponse = true in the wrong event handler (BeforeResponse).  I set bBufferResponse in the BeforeRuquest event and everything works as expected. 
  3. Eric Lawrence
    Eric Lawrence avatar
    832 posts

    Posted 02 Nov 2015 Link to this post

    Hi, Kris--

    Yup, changing it inside BeforeRequest works.

    One helpful thing you can do is prototype your changes in Fiddler itself (using FiddlerScript) before moving to FiddlerCore. 

    If you open your FiddlerScript, you'll see the following note:

        // If a given session has response streaming enabled, then the OnBeforeResponse function 
        // is actually called AFTER the response was returned to the client.
        // In contrast, this OnPeekAtResponseHeaders function is called before the response headers are 
        // sent to the client (and before the body is read from the server).  Hence this is an opportune time 
        // to disable streaming (oS.bBufferResponse = true) if there is something in the response headers 
        // which suggests that tampering with the response body is necessary.

        // Note: oSession.responseBodyBytes is not available within this function!

    In FiddlerCore, the last possible moment to change bBufferResponse is the ResponseHeadersAvailable event.

    Eric Lawrence
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top