Why does CefSharp re-write a URL for custom scheme?

202 views
Skip to first unread message

dirk_...@gmx.de

unread,
Feb 12, 2015, 12:18:18 PM2/12/15
to cefs...@googlegroups.com
I have extended my list of CefSharp samples (see my last post) with a sample that can browse the content of a zip file.
Now, I'd like to extend this sample to be able to browse any zip file on the local file system and I am finding it hard to
understand how to do this because the URL is re-written when I point it to a local path.

To test this, you can have a look at sample 5 and set the address to a local path, like so:

            this.BrowserAddress = "local://C:/temp/web.zip/index.html"; //  AppViewModel.TestResourceUrl;

in the constructor of
https://github.com/Dirkster99/KB/blob/master/00_HelloWorld/KnowledgeBase%20-%20Sample%205%20LocalZipSchemeHandler/KnowledgeBase/ViewModels/AppViewModel.cs

The set a break point at about line 22 in
https://github.com/Dirkster99/KB/blob/master/00_HelloWorld/KnowledgeBase%20-%20Sample%205%20LocalZipSchemeHandler/KnowledgeBase/Models/Cef/LocalZipSchemeHandler.cs

the value of request.Url is now this (the colon character is missing and everything is lower case) :
"local://c/temp/web.zip/index.html"

Now I am not really bothered about the case since the Windows filesystem is case insensitive but I'd like to understand
why this re-write happens and how I should incorporate a local file path into a custom scheme URL?

Alex Maitland

unread,
Feb 15, 2015, 6:25:14 AM2/15/15
to cefs...@googlegroups.com
Reading the `Cef` documentation may shed some light on this see http://magpcss.org/ceforum/apidocs3/projects/%28default%29/CefSchemeRegistrar.html#AddCustomScheme%28constCefString&,bool,bool,bool%29

It would appear that some of the values passed to `AddCustomScheme` are hard coded, so changes to `CefSharp` maybe required for your scenario. Feel free to submit a PR to our github project.

Alex Maitland

unread,
Feb 15, 2015, 7:33:26 AM2/15/15
to cefs...@googlegroups.com
I actually had some relevant changes sitting on another branch, so I've merged them just now.

See https://github.com/cefsharp/CefSharp/commit/415e9ab2c8f62cf37f6cf49d7a9bbe09e244db8b

dirk_...@gmx.de

unread,
Feb 17, 2015, 2:48:06 PM2/17/15
to cefs...@googlegroups.com
Thanks for the quick help. I was actually able to extend the samples such that I know have a WPF sample that can load HTML files from any zip based container stored in the file system:

https://github.com/Dirkster99/KB/tree/master/00_HelloWorld/KnowledgeBase%20-%20Sample%206%20LocalZipSchemeHandler

I also learned from a different comment that I can get the current version 39.0.0 from MyGet.org, which works great for me. Thanks a lot for this great project.
Reply all
Reply to author
Forward
0 new messages