You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For reference here is an updated example in the context of WPF for SetPreference on a newly created RequestContext, same concept applies for WinForms, just create and assign your RequestContext then set your preferences on the CEF UI thread.
If you set the proxy settings through Cef.Initialize, aka command line argument, you won't be able to change them using SetPreference, they'll be fixed. You have to only set them through SetPreference
You will have to create a new RequestContext instance to use this method.
SetPreference must be called on the UI thread and only after the RequestContext has been initialized. The browser initialized events are guaranteed to be called after the RequestContext has been initialized.
If you set the proxy via the command line then you will be unable to modify it using SetPreference.
Activity
amaitland commentedon Sep 24, 2016
Search on Gitter, topic has been covered a few times. Next time please take the time to read the issue template.
amaitland commentedon Sep 25, 2016
For reference here is an updated example in the context of
WPFforSetPreferenceon a newly createdRequestContext, same concept applies forWinForms, just create and assign yourRequestContextthen set your preferences on theCEF UIthread.b3a2369#diff-670f0330cbeb12f911a2f6f4af481dc2L44
More info related to setting proxies is at http://stackoverflow.com/questions/36095566/cefsharp-3-set-proxy-at-runtime
Additional note for anyone else.
[-]different proxy[/-][+]Set Proxy Per Browser[/+]DianaArquillos commentedon Feb 16, 2018
28141932 commentedon Sep 7, 2018
这个应该是你要的答案,我测试过是ok的。
https://stackoverflow.com/questions/48613266/proxy-for-only-one-browser-with-cefsharp-offscreen
ToxaDev commentedon Jan 3, 2020
amaitland commentedon Jan 3, 2020
The browser provides an initialized event, the WinForms/WPF/OffScreen implementation slightly differs, the relevant docs are.
http://cefsharp.github.io/api/75.1.x/html/E_CefSharp_Wpf_ChromiumWebBrowser_IsBrowserInitializedChanged.htm
http://cefsharp.github.io/api/75.1.x/html/E_CefSharp_OffScreen_ChromiumWebBrowser_BrowserInitialized.htm
http://cefsharp.github.io/api/75.1.x/html/E_CefSharp_WinForms_ChromiumWebBrowser_IsBrowserInitializedChanged.htm
If you have multiple browsers that share the RequestContext then using http://cefsharp.github.io/api/75.1.x/html/M_CefSharp_IRequestContextHandler_OnRequestContextInitialized.htm is the option I'd recommend. See https://github.com/cefsharp/CefSharp/blob/cefsharp/75/CefSharp.Wpf.Example/Handlers/RequestContextHandler.cs#L24 for an example.
You will have to create a new RequestContext instance to use this method.
SetPreference must be called on the UI thread and only after the RequestContext has been initialized. The browser initialized events are guaranteed to be called after the RequestContext has been initialized.
If you set the proxy via the command line then you will be unable to modify it using SetPreference.
Further questions please use one of the support options listed at https://github.com/cefsharp/CefSharp#contact
amaitland commentedon Jan 3, 2020
See also https://github.com/cefsharp/CefSharp/wiki/General-Usage#request-context-browser-isolation