I believe I have found a BUG with the EO.WebBrowser's custom resource handler's documentation/logic.
I am following the sample for adding a custom handler, as denoted here:
https://www.essentialobjects.com/doc/webbrowser/advanced/resource_handler.aspxAnd it is not working, when I try to set MyEoWebBrowser.Url = "sample://MyPage.htm". The "Match, nor the "ProcessRequest" ever get called, and instead, an error results, with the "LoadFailed" event getting fired off with a generic error as such:
========================================================================================================================================================================================
- The Page Failed to Load
- The request was canceled.
-
- To customize this message, please handle the WebView's LoadFailed event and then Set e.ErrorMessage in your event handler based on e.ErrorCode,
- or call e.UseDefaultMessage if you just wish to display the error message without this help message.
========================================================================================================================================================================================
I have seen in the forums, this link:
https://www.essentialobjects.com/forum/postst10220_EOWebBrowser-Custom-Handler-never-goes-into-Process.aspxIt details a similar experience, where the person trying to make a custom handler tried to put break points in the "Match" and "ProcessRequest" handler.
Someone from EO replied, saying there is a timeout limit, and to simply remove the break points, and then that person report "It worked".
I never put break points in. Instead, I have "Console.WriteLine" snippets in "Match" and "ProcessRequest" which never get called.
I did try removing those as well, but the error still occurs.
I got my issue fixed, by moving the call to [EO.WebBrowser.Runtime.RegisterCustomSchemes("sample");] before any EO.WebBrowser functionality was called.
My Console.WriteLine calls in Match and ProcessRequest work, and putting a break point in ProcessRequest also works.
I believe thers is a BUG in the documentation, in that the documentation should indicate that this call must be made before any EO.WebBrowser functionality is called.
- This should be indicated here:
https://www.essentialobjects.com/doc/webbrowser/advanced/resource_handler.aspx - and here:
https://www.essentialobjects.com/doc/eo.webbrowser.runtime.registercustomschemes.aspxWhat lead me to try my solution was examining the sample from EO, in the EOPDFDemo, which shows the [EO.WebBrowser.Runtime.RegisterCustomSchemes("sample");] being ran, before any EO.WebBorswer control gets made, in a "LoadSamples" function.