I am using GeckFX45 from NuGet to host a webpage for my OAuth2 login, During testing its behavior without internet connection I noticed that I get a dialog generated by the browser saying the URL could not be found. How can I suppress this to I can catch and handle the scenario in my app without alerting user?
My browser code is pretty standard, but for arguments sake included here anyway (Note I am using WPF not Win Forms hence the host control):
public OAuthLogin2(OAuthActions action, string args = null)
{
this.action = action;
Gecko.Xpcom.Initialize("Firefox");
host = new WindowsFormsHost();
browser = new GeckoWebBrowser();
browser.DocumentCompleted += Browser_DocumentCompleted;
browser.Navigating += Browser_Navigating;
browser.NavigationError += Browser_NavigationError;
browser.NSSError += Browser_NSSError;
InitializeComponent();
host.Child = browser;
GridWeb.Children.Add(host);
}
I can add a PromptService
, but this may not work depending on language;
public class NoPromptService : PromptService
{
public override void Alert(string dialogTitle, string text)
{
log.Warn(dialogTitle, new Exception(text));
if (text.EndsWith("could not be found. Please check the name and try again."))
{
// Do Whatever
}
}
}
Add this in constructor:
PromptFactory.PromptServiceCreator = () => new NoPromptService();