Loading Html - chromelyapps/Chromely.Legacy GitHub Wiki
In the following code snippets, the HTML file is stored under app/chromely.html. It's not required to be under app/. Feel free to create your file structure as you see fit, this is just an example.
This will launch actual website URL. This may not necessarily be commonly used as Chromely is focused on loading local HTML5 files for Single Page Applications. This URL should also be of scheme and domain combination that is not registered as external URL scheme. For external URL scheme registration, please see.
class Program
{
static int Main(string[] args)
{
string startUrl = "https://google.com";
//...
}
}For more information please visit Chromely Apps.
This is the preferred way of loading local HTML5 files.
You can either:
- Use the default local resource scheme handling or create a custom one. (Please see samples - CefSharp, CefGlue)
- Use the default scheme handler or registering a new one.
class Program
{
static int Main(string[] args)
{
string startUrl = "local://app/chromely.html";
var config = ChromelyConfiguration
.Create()
//...
.UseDefaultResourceSchemeHandler("local", string.Empty);
//Or register new resource handler
//RegisterSchemeHandler("local", string.Empty, new CustomResourceHandler())
//...
}
}class Program
{
static int Main(string[] args)
{
string startUrl = "local://app/chromely.html";
var config = ChromelyConfiguration
.Create()
//...
.UseDefaultHttpSchemeHandler("http", "chromely.com")
//Or register new http scheme handler
//RegisterSchemeHandler("http", "example.com", new CustomHttpHandler())
//...
}
}Local HTML5 files can also be loaded using file protocol (file:///). Using file protocol (file:///) is discouraged for security reasons. One issue might be Cross-Origin domain. Although not the preferred way, it is useful if HTML/Ajax XHR requests are required.
You can either:
- Use the default local resource scheme handling or create a custom one. (Please see samples - CefSharp, CefGlue)
- Use the default scheme handler or registering a new one.
class Program
{
static int Main(string[] args)
{
var appDirectory = AppDomain.CurrentDomain.BaseDirectory;
string startUrl = $"file:///{appDirectory}app/chromely.html";
var config = ChromelyConfiguration
.Create()
//...
.UseDefaultResourceSchemeHandler("local", string.Empty);
//Or register new resource handler
//RegisterSchemeHandler("local", string.Empty, new CustomResourceHandler())
//...
}
}class Program
{
static int Main(string[] args)
{
var appDirectory = AppDomain.CurrentDomain.BaseDirectory;
string startUrl = $"file:///{appDirectory}app/chromely.html";
var config = ChromelyConfiguration
.Create()
//...
.UseDefaultHttpSchemeHandler("http", "chromely.com")
//Or register new http scheme handler
//RegisterSchemeHandler("http", "example.com", new CustomHttpHandler())
//...
}
}