我在winform中使用CefSharp来显示一个html页面,其中我有一些数据要传递和显示。这是代码:
private CefSharp.WinForms.ChromiumWebBrowser chromiumWebBrowser1;
string html = Utils.GetEmbeddedResource(htmlFilePath);
html = html.Replace("/*NODES*/", nodesJson);
BrowserSettings settings = new BrowserSettings {
DefaultEncoding = "utf-8"
};
chromiumWebBrowser1.BrowserSettings = settings;
chromiumWebBrowser1.LoadHtml(html, base64Encode: true);
当它尝试加载 html 时,发生错误:
[0901/180248.815:WARNING:navigation_controller_impl.cc(283)] Refusing to load URL as it exceeds 2097152 characters.
我打印了html的长度,是2250120,如何处理长html数据?请帮助我,谢谢!
如果未提供
Url
,则使用 Data URI。这对数据 URI 的大小有硬性限制。
如果您提供
Url
作为第二个参数,则使用不同的 ResourceHandler 来加载您的 URL。
示例
chromiumWebBrowser1.LoadHtml(html, "http://myapp.test/index.html");
https://cefsharp.github.io/api/113.1.x/html/M_CefSharp_WebBrowserExtensions_LoadHtml_2.htm