title: How can I change my CefSharp browser's user agent string and proxy?
body: <p>I already know how to set my CefSharp browser's <strong>starting</strong> user agent and proxy. But, I don't know how to <strong>change</strong> my browser's user agent and proxy while the program is running.</p>
  
  <p>How can I change my CefSharp browser's user agent string to the text contents of <em>UserAgentStringTextBox</em> whenever I click the <em>LoadUserAgentStringButton</em> button?</p>
  
  <p>How can I change my CefSharp browser's proxy to the text contents of <em>ProxyTextBox</em> whenever I click the <em>LoadProxyButton</em> button?</p>
  
  <p>I've tried the following code, but it didn't visibly do anything:</p>
  
  <pre><code>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);
          }
      }
  }
  </code></pre>
  
  <p>The following 2 pictures show what happens when I load the website "whatsmyuseragent.com" <strong>WITHOUT</strong> attempting to change the default user agent string (Hello!) and proxy (111.47.13.3:80).</p>
  
  <p><img src="https://i.stack.imgur.com/AEzog.png" width="500" height="500">
  <img src="https://i.stack.imgur.com/XDLNG.png" width="500" height="500"></p>
  
  <p>The following 2 pictures show what happens when I load the website "whatsmyuseragent.com" <strong>WITH</strong> attempting to change the default user agent string (Hello!) and proxy (111.47.13.3:80) -----> to the user agent string "Hey!" and proxy "213.85.92.10:80".</p>
  
  <p><img src="https://i.stack.imgur.com/zhUbJ.png" width="500" height="500">
  <img src="https://i.stack.imgur.com/Jvsj7.png" width="500" height="500"></p>
  
  <p>Which, as you can see, was unsuccessful.</p>
  
  <h1><strong>Thank you for taking the time to read my question!</strong></h1>