Page 1 of 1

ChromiumWebBrowser BrowserSettings

PostPosted: Mon May 16, 2022 4:14 pm
by sidg
Hello All,

I feel silly for having to ask this in the forum but I am kind of stuck. I need to allow use of local files, and thus need to set the appropriate BrowserSettings but I can't find a way to instantiate a BrowserSettings object to do that. The IBrowserSettings exists in the CefSharp namespace and there is a settable BrowserSettings property of that type but how do I create a concrete instance from code behind?

I am using version 94.

Thanks for any help!

Re: ChromiumWebBrowser BrowserSettings

PostPosted: Tue May 17, 2022 1:59 am
by amaitland
new CefSharp.BrowserSettings() should work

Re: ChromiumWebBrowser BrowserSettings

PostPosted: Tue May 17, 2022 6:06 am
by sidg
Yes, it was silly. I was not including CefSharp.Core.dll. Although setting them seems to have no effect. If I try to do it after the browser has been created, I get an exception telling me I can't do that. If I try to do it at the instantiation of the ChromiumWebBrowser, it seems to work, temporarily, and then at some point during the initialization BrowserSettings get reset to null.

Not sure what the appropriate way to set them is.

I ended up achieving my goal by using a self-hosted web api, but I am curious what I am doing wrong on the BrowserSettings.

Re: ChromiumWebBrowser BrowserSettings

PostPosted: Tue May 17, 2022 2:30 pm
by amaitland
The property is null after the underlying CEF browser instance has been created. This is nothing to worry about. Sounds like it was working.

Using local files is not recommend as the file scheme has very different behaviour/restrictions.

You don't need to use a local webserver, you can use a scheme handler for loading of local resources. https://github.com/cefsharp/CefSharp/wi ... me-handler