常規方法:
var setting=new CefSetting(); setting.CefCommandLineArgs.add("proxy-server",ProxyAdd:Port); Cef.Initialize(settings);
但是Cef.Initialize(settings)只能初始化一次 不過user-agant可以多次是修改
測試可用的:
async private void SetProxy(ChromiumWebBrowser cwb, string Address) { await Cef.UIThreadTaskFactory.StartNew(delegate { var rc = cwb.GetBrowser().GetHost().RequestContext; var v = new Dictionary<string,object>(); v["mode"] = "fixed_servers"; v["server"] = Address; string error; bool success = rc.SetPreference("proxy", v, out error); }); }
可以在Cef.Initialize(settings)初始化後調用如上方法即可完成切換