Welcome Guest Search | Active Topics | Sign In | Register

BUG - Custom Handler not getting called. Options
JSB
Posted: Friday, July 21, 2017 11:53:41 AM
Rank: Advanced Member
Groups: Member

Joined: 1/2/2017
Posts: 32
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.aspx
And 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.aspx
It 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.aspx

What 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.
eo_support
Posted: Monday, July 24, 2017 11:35:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Thanks for sharing. Yes, you are correct, all EO.WebBrowser.Runtime methods/properties needs to be set before any WebView is created. Those values are applied on the engine level and they are only applied when the engine starts. We will see if we can clarify this in our documentation.

You can find more details about Engine object here if you are interested:

https://www.essentialobjects.com/doc/webbrowser/advanced/engine.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.