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

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

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

Postby Maximqq » Sat Sep 16, 2023 4:55 am

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
Maximqq
Newbie
 
Posts: 2
Joined: Sat Sep 16, 2023 4:51 am

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

Postby amaitland » Mon Sep 18, 2023 2:54 am

Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1312
Joined: Wed Jan 14, 2015 2:35 am

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

Postby Maximqq » Wed Sep 20, 2023 5:03 am

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
Maximqq
Newbie
 
Posts: 2
Joined: Sat Sep 16, 2023 4:51 am

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

Postby amaitland » Thu Sep 21, 2023 9:17 pm

You need to find the equivalent preference if one exists.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1312
Joined: Wed Jan 14, 2015 2:35 am


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 1 guest