Hi,
You can not do this through BeforeNavigate event. BeforeNavigate event is called in a worker thread so you can not do any of those things that you normally do in your main UI thread. Because BeforeNavigate runs in a worker thread, inside that event you can only perform some non-UI related check and return as quickly as you can.
The safest way to do this is with JavaScript. The basic steps are:
1. Write the JavaScript code that searches for all A element in your HTML and attach onclick handler to them;
2. When user click the link, your JavaScript onclick handler is triggered. Inside your JavaScript code you can use eoapi.extInvoke to call into your C# code. This call will be in main UI thread so you will be able to do pretty much everything you normally do;
3. Depending on the return value of your C# side code, you can then decide whether to cancel or proceed with the navigation;
Note that we do not provide tech support on JavaScript code. But intercepting link is common and if you search online, you should be able to find plenty of sample code.
Once you have the correct JavaScript code to do that, you can run the code using webView.EvalScript. You can call this method this way:
Code: C#
//Load the HTML and wait for it to finish
NavigationTask task = webView.LoadHtml(your_html);
task.WaitOne();
//Run your JavaScript code
webView.EvalScript(your_script);
See here for more information on how to call C# code from your JavaScript code:
https://www.essentialobjects.com/doc/webbrowser/advanced/jsext.aspxHope this helps.
Thanks!