Page 1 of 1

cefsharp latest version (v116.0.230) skip host-resolver-rule

PostPosted: Sat Sep 16, 2023 4:55 am
by Maximqq
Code: Select all
private void startAsync()
{

    Cef.UIThreadTaskFactory.StartNew(delegate
    {

        try
        {
            // Create a new RequestContext for the new form
            RequestContext requestContext = new RequestContext();

            // Create a dictionary to store the proxy settings
            var proxySettings = new Dictionary<string, object>();
            proxySettings["mode"] = "fixed_servers";
            proxySettings["server"] = "*proxy*";
            string error;
            bool success = requestContext.SetPreference("proxy", proxySettings, out error);
            if (!success)
            {
                Console.WriteLine("Failed to set proxy preference: " + error);
            }

            success = requestContext.SetPreference("host-resolver-rules", "MAP ripe.net 127.0.0.1:8080", out error);
            if (!success)
            {
                Console.WriteLine("Failed to set host-resolver-rules preference: " + error);
            }

            // Create a new form
            Form frm = new Form();
            frm.Text = "New Form";
            frm.Width = 600;
            frm.Height = 400;

            ChromiumWebBrowser browser = new ChromiumWebBrowser();
            browser.Dock = DockStyle.Fill;

            // Assign the RequestContext to the browser
            browser.RequestContext = requestContext;

            // Load the URL in the browser
            browser.Load("http://ripe.net/");

            frm.Controls.Add(browser);
            frm.Show();
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    });
}


Can you please tell me why cef misses my host-resolver-rules parameter? I need to do it exactly when creating a browser. Every time my site will be new. I can create settings only 1 time.

Proxy work

Re: cefsharp latest version (v116.0.230) skip host-resolver-

PostPosted: Mon Sep 18, 2023 2:54 am
by amaitland

Re: cefsharp latest version (v116.0.230) skip host-resolver-

PostPosted: Wed Sep 20, 2023 5:03 am
by Maximqq
amaitland wrote:https://stackoverflow.com/questions/77113053/c-sharp-cefsharp-host-resolver-rules-parameter-does-not-work-skip#comment135944987_77113053

Work only in setting

i need work in Cef.UIThreadTaskFactory.StartNew

Re: cefsharp latest version (v116.0.230) skip host-resolver-

PostPosted: Thu Sep 21, 2023 9:17 pm
by amaitland
You need to find the equivalent preference if one exists.