fix(.NET): resolve cefsharp not loading uris with special characters

Before this change, the browser would fail to navigate to the local index.html page if the path leading to the file contained any special characters. This resulted in the browser loading into a file view.

This fix adds a custom URI scheme that retains the same base directory that was in use previously and sets the default file to index.html. This resolves the issue with cefsharp not loading uris with special characters.
This commit is contained in:
Teacup
2023-02-11 16:21:38 -05:00
parent b5916d0a50
commit 8aae8f3b78
2 changed files with 11 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
using CefSharp;
using CefSharp.SchemeHandler;
using CefSharp.WinForms;
using System;
using System.IO;
@@ -26,12 +27,16 @@ namespace VRCX
PersistUserPreferences = true
};
/*cefSettings.RegisterScheme(new CefCustomScheme
cefSettings.RegisterScheme(new CefCustomScheme
{
SchemeName = "vrcx",
DomainName = "app",
SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html")
});*/
SchemeName = "localnjs",
DomainName = "vrcx",
SchemeHandlerFactory = new FolderSchemeHandlerFactory(
rootFolder: Path.Combine(Program.BaseDirectory, "html"),
hostName: "vrcx",
defaultPage: "index.html"
)
});
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
// cefSettings.CefCommandLineArgs.Add("ignore-certificate-errors");