I have a CefSharp browser created in my Winform, and I need to dynamically create an HTML page in memory and then CefSharp display it.
Ideally, I would like to pass the constructor a string with HTML in it, but it expects a URL. The answer is probably not, but is there a directive that you can add to the string so that CefSharp knows that it is a string containing the web page? Then will CefSharp create a temporary file?
If not, where is the chromatic temp folder installed? Will it work if I write the file there and then pass this as a fully qualified path? I know that Chrome will support something like a file: ///Users/dmacdonald/Documents/myFile.htm as a URL, but not sure how to form the URL if the temp structure is used.
Here is my new code, but my browser object does not have a ResourceHandler property. I see that it has a ResourceHandlerFactory
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using CefSharp.WinForms; using CefSharp; namespace DanCefWinForm { public partial class Form1 : Form { public const string TestResourceUrl = "http://maps/resource/load"; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { ChromiumWebBrowser browser = new ChromiumWebBrowser("http://maps/resource/load") { Dock = DockStyle.Fill, }; var handler = browser.ResourceHandler; browser.Location = new Point(20, 20); browser.Size = new Size(100, 100); this.Controls.Add(browser); } } }
c # chromium-embedded cefsharp
user461051
source share