Fiddlercore: how to block and redirect sites

喜夏-厌秋 提交于 2019-12-11 08:35:58

问题


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


回答1:


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;
}


来源:https://stackoverflow.com/questions/25384263/fiddlercore-how-to-block-and-redirect-sites

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!