private async void OnNavigated(object sender, WebBrowserNavigatedEventArgs e) { Debug.WriteLine("Navigated " + e.Url); // Pre-Authorization performed? if (m_isPreAuthorization) { m_isPreAuthorization = false; m_browser.Navigate(m_provider.AuthorizationUrl); return; } // we need to ignore all navigation that isn't to the redirect uri. if (!e.Url.ToString().StartsWith(m_provider.RedirectionUrl.ToString(), StringComparison.OrdinalIgnoreCase)) { return; } try { var isOk = await m_provider.Claim(e.Url, m_browser.DocumentTitle); DialogResult = isOk ? DialogResult.OK : DialogResult.Cancel; } catch { DialogResult = DialogResult.Cancel; } finally { m_browser.Stop(); Close(); } }
private async void OnNavigated(object sender, WebBrowserNavigatedEventArgs e) { Debug.WriteLine("Navigated " + e.Url); // Pre-Authorization performed? if (m_isPreAuthorization) { m_isPreAuthorization = false; m_browser.Stop(); m_browser.Navigate(m_provider.AuthorizationUrl); return; } // we need to ignore all navigation that is already claimed or could not be claimed (due to missing code). if (m_isClaimed || !m_provider.CanClaim(e.Url, m_browser.DocumentTitle)) { return; } m_isClaimed = true; m_browser.Stop(); m_browser.Visible = false; m_pnlWait.Visible = true; try { var isOk = await m_provider.Claim(e.Url, m_browser.DocumentTitle); DialogResult = isOk ? DialogResult.OK : DialogResult.Abort; } catch (Exception ex) { this.LastException = ex; DialogResult = DialogResult.Abort; } finally { Close(); } }