Generate LoadError in Scheme Handler

49 views
Skip to first unread message

Ken Thomas

unread,
Jun 4, 2015, 5:25:48 PM6/4/15
to cefs...@googlegroups.com
I have implemented ISchemeHandler to handle my own scheme via HttpWebRequest.  Everything works fine.  Up until something goes wrong... :)

Say I get a WebException during HttpWebRequest.GetResponse().  As I process the exception, I'd like to trigger ChromiumWebBrowser.LoadError event so that my error processing can follow the same path as the rest of my requests that are handled by CefSharp.

How can I generate a LoadError event when doing my own request processing?  Is there something I can set on the response object?

Is there a better solution for handling requests in my scheme handler and notifying the app that a network error occured?

Ken Thomas

unread,
Jun 4, 2015, 5:27:11 PM6/4/15
to cefs...@googlegroups.com
I should have said I'm using CefSharp.WinForms v37.

Bill Tutt

unread,
Jun 9, 2015, 6:12:41 PM6/9/15
to cefs...@googlegroups.com
Can't you just set the error response data from WebException and populate your response with that?
If it doesn't have a HTTP Status Code set (for other odd reasons) you can pick one of the HTTP failure codes to use instead. (i.e. 404, or whatever...)

I don't know whether or not that would cause a LoadError event though.

Bill

Alex Maitland

unread,
Jun 10, 2015, 7:39:38 AM6/10/15
to cefs...@googlegroups.com
The underlying callback exposes a `Cancel` method that if called triggers an `Aborted` error.

It's not exposed in the current version though. It'll be there in the next major release (probably `43`)
https://github.com/cefsharp/CefSharp/pull/1053/files#diff-f3168e83192e7cc4bde92c428e9a4cedR45

For now, trying to set the StatusCode is probably the best bet.
Reply all
Reply to author
Forward
0 new messages