Search code examples
proxycefsharp

In CefSharp, how to disable proxy while the program is running


Now, I already know how to modify the network proxy. But i want to disable it, not modify it.

Cef.UIThreadTaskFactory.StartNew(delegate {
      var rc = chromeBrowser.GetBrowser().GetHost().RequestContext;
      var v = new Dictionary<string, object>();
      v["mode"] = "fixed_servers";
      v["server"] = "scheme://server:port;
      string error;
      bool success = rc.SetPreference("proxy", v, out error);                
    });   

I want to implement it like

var cefSettings = new CefSharp.CefSettings();
cefSettings.CefCommandLineArgs.Add("no-proxy-server","1");

but, I want to disable proxy at runtime


Solution

  • 1) You must not use CefCommandLineArgs that setting proxy. You must set proxy how you written above.You must set proxy behind Cef.Initialize() how you written above.

    2)Replace mode to "DIRECT" - it disabled connection with proxy.

    v["mode"] = "direct";
    

    3) You can check actual connection information if you will loading page "chrome://net-internals#proxy"