Hello, this is my first time using FiddlerCore and am trying to grasp the concepts behind it. I am developing a simple project that should block websites that are specified in a database, and block all sites if the user is browsing at a time that is set by the administrator. It is for a school project. For now, I have hard-coded the site I want blocked: "facebook.com". Below is the code:
void FiddlerApplication_BeforeRequest(Session oSession)
{
if (oSession.url.Contains("facebook.com"))
{
oSession.utilCreateResponseAndBypassServer();
oSession.oResponse.headers.SetStatus(307, "Redirect");
oSession.oResponse["Cache-Control"] = "nocache";
oSession.oResponse["Location"] = "http://microsoft.com";
oSession.utilSetResponseBody(GenerateErrorMessage("Internet Time", "The request was set at a time interval that is blocked by the " +
"administrator(s) of this computer", oSession.fullUrl, "--"));
return;
}
}
However, I am getting an ERR_TUNNEL_CONNECTION_FAILED message in google chrome and I am getting a page cannot be displayed in internet explorer. Basically what I would like is if a site is block, display the html in the browser specified in oSession.utilSetResponseBody(GenerateErrorMessage("Internet Time", "The request was set at a time interval that is blocked by the " + "administrator(s) of this computer", oSession.fullUrl, "--"));
This works in all sites that do not have "https:". For ex: I am getting my desired result that I want if I try to block "microsoft.com".
Any help is appreciated.