I am trying to load local html/css/js files using CefSharp v65 in WinForms.
I found other stack overflow posts regarding this but none of them used the new built-in version of FolderSchemeHandlerFactory
, instead implementing their own version. Here is the documentation I read on the Scheme Handler: https://github.com/cefsharp/CefSharp/wiki/General-Usage under the "Scheme Handler" header.
Sources: Working with locally built web page in CefSharp
I tried using the new feature like so:
public ChromiumWebBrowser browser;
public void InitBrowser()
{
var settings = new CefSettings();
settings.RegisterScheme(new CefCustomScheme
{
SchemeName = "localfolder",
SchemeHandlerFactory = new FolderSchemeHandlerFactory(
rootFolder: @"..\..\..\..\CEFSharpExample\webpage",
defaultPage: "index.html" // default
)
});
Cef.Initialize(settings);
string html = File.ReadAllText(@"..\..\..\webpage\index.html");
browser = new ChromiumWebBrowser();
browser.LoadHtml(html);
this.Controls.Add(browser);
browser.Dock = DockStyle.Fill;
}
However, I am simply getting the html with no css, with no exceptions in the debugger. Does anyone understand how to leverage the new built-in functionality?