fiddlerfiddlercorefiddler-dev

Fiddlercore: how to block and redirect sites


Fiddler core .net api proxy server captures network traffic.

  1. how to redirect any http/https url to another site.?

    suppose if I browse yahoo.com, then proxy server should redirect to another site such as wikipedia.com. Browser should open wikipedia instead of yahoo.com.

  2. how to block any web site.?

    suppose when I hit espncricinfo.com in browser, then site must be blocked and stopped its session


Solution

  • These topics are well-covered in the Fiddler book and in numerous tutorials around the web.

    Inside your BeforeRequest handler, add code that examines the request and returns a redirect (or an error page)

    if (oSession.urlContains("whatever"))
    {
       oS.utilCreateResponseAndBypassServer();
       oS.oResponse.headers.SetStatus(307, "Redirect");
       oS.oResponse["Cache-Control"] = "nocache";
       oS.oResponse["Location"] = "http://newurl/";
       oS.utilSetResponseBody("<html><body>sending request elsewhere</body></html>"); 
       return;
    }