private void WebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { Uri uri = new Uri(e.FailedUrl); Debug.Print("WebBrowser_LoadError >> e.FailedUrl : " + e.FailedUrl); // get th host name from the full URL, e.g.: // https://myhost.com >> myhost.com string host = tbxCallbackUrl.Text.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[1].ToLower(); if (uri.Host.ToLower() == host) { // Get the code string code = HttpUtility.ParseQueryString(uri.Query).Get("code"); // Navigate to something else to remove the // bad page webBrowser.Load(null); // Turn the code into access token var authApi = new ThreeLeggedApi(); var response = authApi.Gettoken(tbxClientId.Text, tbxClientSecret.Text, "authorization_code", code, tbxCallbackUrl.Text); logInInfo.accessToken = response["access_token"]; logInInfo.refreshToken = response["refresh_token"]; logInInfo.expiresIn = response["expires_in"]; logInInfo.clientId = tbxClientId.Text; logInInfo.clientSecret = tbxClientSecret.Text; //this.DialogResult = DialogResult.OK; //this.Close(); closeDialog(); } }
private void WebView_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { Trace.WriteLine(new LogMessage("WebCef", "WebView_LoadError: Cannot navigate. e = " + e.ToString()), LogType.Error.ToString()); // This should exipre the media Duration = 5; base.RestartTimer(); }
private void Load_Error(object sender, CefSharp.LoadErrorEventArgs e) { Dispatcher.Invoke(() => { loadingError.Visibility = Visibility.Visible; errorCode.Content += e.ErrorCode.ToString(); errorDesc.Content += e.ErrorText.ToString(); }); }
// if a some kind of loading error occurred.. private void Browser_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { if (this.IsHandleCreated) // an exception might occur: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." { VPKSoft.ErrorLogger.ExceptionLogger.LogMessage(e.ErrorText); // Log the browser error's text.. this.Invoke(new MethodInvoker(delegate() // Set the button states with an invoke call as the browser runs in a different thread.. { lbUrl.Text = // show a message int the URL label that the navigation failed.. string.Format( DBLangEngine.GetMessage( "msgInvalidURL", "The given URL is invalid: '{0}'.|A navigation error occurred in a web browser form."), e.FailedUrl); } )); } }
/// <summary> /// Executes when loading error is occured. /// /// Basically, show an html page for each error. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void WebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { // Save the original url string originalUrl = null; this.NavigationBar.Dispatcher.Invoke(() => originalUrl = this.NavigationBar.urlTextBox.Text); // In case error aborted by CEF, do nothing if (e.ErrorCode == CefSharp.CefErrorCode.Aborted) { return; } // Handle loading errors string errorPagePath = string.Empty; if (OrganicUtility.IsConnected() == false) { // In case of no internet errorPagePath = "organic://error/no_internet"; } else if (e.ErrorCode == CefSharp.CefErrorCode.NameNotResolved) { // In case of domain could not be resolved errorPagePath = "organic://error/could_not_resolve"; } else { // Default loading error page System.Console.WriteLine(e.ErrorText); errorPagePath = "organic://error/general"; } // Handle more loading errors here // Load the error page this.WebBrowser.Dispatcher.Invoke(() => this.WebBrowser.Address = OrganicUtility.GetLocalPageActualUrl(errorPagePath)); // Restore the url this.NavigationBar.Dispatcher.Invoke(() => this.NavigationBar.urlTextBox.Text = originalUrl); }
private void W_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { if (e.FailedUrl.StartsWith(RedirectUri, StringComparison.InvariantCultureIgnoreCase)) { try { OAuth2Response result = DropboxOAuth2Helper.ParseTokenFragment(new Uri(e.FailedUrl)); if (result.State == oauth2State) { w.Invoke((MethodInvoker)(() => w.Hide())); Properties.Settings.Default.AccessToken = result.AccessToken; Properties.Settings.Default.Save(); Invoke((MethodInvoker)(() => InitClient(result.AccessToken))); } } catch (ArgumentException) { MessageBox.Show("There was an error"); } } }
private void WebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { //重置任务 if (e.Frame.IsMain) { if (currentTask != null && (currentTask.webState == EWebbrowserState.Start || currentTask.webState == EWebbrowserState.Search || currentTask.webState == EWebbrowserState.SearchSite || currentTask.webState == EWebbrowserState.AccessSite || currentTask.webState == EWebbrowserState.AccessPage)) { e.Browser.StopLoad(); ShowTaskEvent(this, new AppEventArgs() { message_string = string.Format("加载网页发生错误{0}网址{1},重新执行,任务{2}", e.ErrorText, e.FailedUrl, currentTask.nID) }); StartSearch(this, new AppEventArgs() { message_task = currentTask }); } } //throw new NotImplementedException(); }
private void Browser_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { }
private void ChromiumWebBrowser1_LoadError(object sender, CefSharp.LoadErrorEventArgs e) { // We should get this on the localhost load BeginInvoke((MethodInvoker) delegate { textBox1.Text = e.FailedUrl; Refresh(); }); // FailedUrl is correct and we can get the info out of it }