I am creating a headless browser using Awesomium. I want the browser to return Network Error codes, so I know how/why it's breaking.
using (WebSession session = WebCore.CreateWebSession(new WebPreferences() { CustomCSS = "::-webkit-scrollbar { visibility: hidden; }" }))
{
using (WebView browserTab = WebCore.CreateWebView(1100, 600, session))
{
Console.WriteLine($"Starting WebCore v{WebCore.Version}");
BadExample(browserTab, baseURL);
}
}
static void BadExample(WebView browser, Uri url) {
browser.Source = (url + "/anyhing").ToUri();
browser.LoadingFrameComplete += (sender, returnFrame) =>
{
//NetError Code
};
}
How do I use enum NetError to return the values I want?
You should subscribe to event
IWebView.LoadingFrameFailed(browser in your case).As long as there can be many frames on a page, the event will fire for every frame. Below is a snippet that I use in my project.