#pragma warning disable 618 // WebBrowserNavigateErrorEventArgs is marked obsolete
        protected virtual void OnNavigateError(WebBrowserNavigateErrorEventArgs e)
        {
            if (NavigateError != null)
            {
                NavigateError(this, e);
            }
        }
        /// <summary>
        /// </summary>
        protected virtual void WebBrowserNavigateErrorHandler(object sender, WebBrowserNavigateErrorEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                e.Cancel = true;
                return;
            }

            if (_webBrowser.IsDisposed)
            {
                // we cancel all flow in disposed object.
                e.Cancel = true;
                return;
            }

            if (_webBrowser.ActiveXInstance != e.WebBrowserActiveXInstance)
            {
                // this event came from internal frame, ignore this.
                return;
            }

            if (e.StatusCode >= 300 && e.StatusCode < 400)
            {
                // we could get redirect flows here as well.
                return;
            }

            e.Cancel = true;
            StopWebBrowser();
            // in this handler object could be already disposed, so it should be the last method
            OnNavigationCanceled(e.StatusCode);
        }
Exemple #3
0
            public void NavigateError(object pDisp, ref object url, ref object frame, ref object statusCode,
                                      ref bool cancel)
            {
                string uriString     = (url == null) ? "" : ((string)url);
                string frameString   = (frame == null) ? "" : ((string)frame);
                int    statusCodeInt = (statusCode == null) ? 0 : ((int)statusCode);

#pragma warning disable 618 // WebBrowserNavigateErrorEventArgs is marked obsolete
                WebBrowserNavigateErrorEventArgs e = new WebBrowserNavigateErrorEventArgs(uriString, frameString,
                                                                                          statusCodeInt, pDisp);
#pragma warning restore 618
                parent.OnNavigateError(e);
                cancel = e.Cancel;
            }