c# - How can I change my CefSharp browser's user agent string and proxy? -
i know how set cefsharp browser's starting user agent , proxy. but, don't know how change browser's user agent , proxy while program running.
how can change cefsharp browser's user agent string text contents of useragentstringtextbox whenever click loaduseragentstringbutton button?
how can change cefsharp browser's proxy text contents of proxytextbox whenever click loadproxybutton button?
i've tried following code, didn't visibly anything:
using cefsharp; using cefsharp.winforms; using system.windows.forms; namespace proxy { public partial class proxyform : form { private chromiumwebbrowser browser; private cefsettings settings; public proxyform() { initializecomponent(); initializewebbrowser(); } private void initializewebbrowser() { settings = new cefsettings(); settings.cefcommandlineargs.add("proxy-server", "111.47.13.3:80"); settings.useragent = "hello!"; cef.initialize(settings); browser = new chromiumwebbrowser(string.empty) { dock = dockstyle.fill }; controls.add(browser); } private void loadproxybutton_click(object sender, system.eventargs e) { settings.cefcommandlineargs.remove("proxy-server"); settings.cefcommandlineargs.add("proxy-server", proxytextbox.text); } private void loaduseragentstringbutton_click(object sender, system.eventargs e) { settings.useragent = useragentstringtextbox.text; } private void loadwebsitebutton_click(object sender, system.eventargs e) { browser.load(websitetextbox.text); } } }
the following 2 pictures show happens when load website "whatsmyuseragent.com" without attempting change default user agent string (hello!) , proxy (111.47.13.3:80).
the following 2 pictures show happens when load website "whatsmyuseragent.com" with attempting change default user agent string (hello!) , proxy (111.47.13.3:80) -----> user agent string "hey!" , proxy "213.85.92.10:80".
which, can see, unsuccessful.
thank taking time read question!
Comments
Post a Comment