Friday, June 26, 2009

Resolution of Operation Aborted error in IE7 for an ESRI ArcGIS 9.3 Web ADF application

This post is merely a summary of work done by others.  My colleague, Paul Angelino, put the pieces together.  His work was based off of two other blog posts, one from ESRI and another from Joel Rumerman.  Joel determined the cause of the problem and provided a solution.

I’m making this post because it took Paul a while to figure out how to implement Joel’s solution, so I’m hoping this post provides clarity.

Our ASP.NET Web ADF application has a master page containing a MapResourceManager.  The Map control is located on the content page.  The solution was to place Joel’s javascript fix as the very last line in the aspx page:

    <script language="javascript" type="text/javascript" src="javascript/AjaxFix.js"></script>
</asp:Content>


Here is the AjaxFix.js file:



//
// Paul Angelino, 6/12/2009
// This code is a workaround to a known issue with IE and ASP.NET Ajax where an "Operation Aborted" popup error
// would occur sporadically.  This effectively replaces some of the out-of-the-box ASP.NET Ajax functions.
// Correct placement of this code within an .aspx file is essential to it working properly.  See the following
// links for more information on the issue and the workiaround:
//      http://forums.esri.com/Thread.asp?c=158&f=2272&t=255293
//      http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2008/09/08/Operation-aborted-error-in-Internet-Explorer.aspx 
//      http://seejoelprogram.wordpress.com/2008/10/03/fixing-sysapplicationinitialize-again/
//
Sys.Application.initialize = function Sys$_Application$initialize() {
    if (!this._initialized && !this._initializing) {
        this._initializing = true;
        var u = window.navigator.userAgent.toLowerCase(),
                          v = parseFloat(u.match(/.+(?:rv|it|ml|ra|ie)[\/: ]([\d.]+)/)[1]);
        var initializeDelegate = Function.createDelegate(this, this._doInitialize);
        if (/WebKit/i.test(u) && v < 525.13) {
            this._load_timer = window.setInterval(function() {
                if (/loaded|complete/.test(document.readyState)) {
                    initializeDelegate();
                }
            }, 10);
        }
        else if (/msie/.test(u) && !window.opera) {
            document.attachEvent('onreadystatechange',
                              function(e) {
                                  if (document.readyState == 'complete') {
                                      document.detachEvent('on' + e.type, arguments.callee);
                                      initializeDelegate();
                                  }
                              }
                          );
            if (window == top) {
                (function() {
                    try {
                        document.documentElement.doScroll('left');
                    } catch (e) {
                        setTimeout(arguments.callee, 10);
                        return;
                    }
                    initializeDelegate();
                })();
            }
        }
        else if (document.addEventListener
                          && ((/opera\//.test(u) && v > 9) ||
                              (/gecko\//.test(u) && v >= 1.8) ||
                              (/khtml\//.test(u) && v >= 4.0) ||
                              (/webkit\//.test(u) && v >= 525.13))) {
            document.addEventListener("DOMContentLoaded", initializeDelegate, false);
        }
        else {
            $addHandler(window, "load", initializeDelegate);
        }
    }
}
Sys.Application._doInitialize = function Sys$_Application$_doInitialize() {
    if (this._initialized) {
        return;
    }
    Sys._Application.callBaseMethod(this, 'initialize');
    if (this._load_timer !== null) {
        clearInterval(this._load_timer);
        this._load_timer = null;
    }
    var handler = this.get_events().getHandler("init");
    if (handler) {
        this.beginCreateComponents();
        handler(this, Sys.EventArgs.Empty);
        this.endCreateComponents();
    }
    if (Sys.WebForms) {
        this._beginRequestHandler = Function.createDelegate(this, this._onPageRequestManagerBeginRequest);
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(this._beginRequestHandler);
        this._endRequestHandler = Function.createDelegate(this, this._onPageRequestManagerEndRequest);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(this._endRequestHandler);
    }
    var loadedEntry = this.get_stateString();
    if (loadedEntry !== this._currentEntry) {
        this._navigate(loadedEntry);
    }
    this.raiseLoad();
    this._initializing = false;
}
Sys.Application._loadHandler = function Sys$_Application$_loadHandler() {
    if (this._loadHandlerDelegate) {
        Sys.UI.DomEvent.removeHandler(window, "load", this._loadHandlerDelegate);
        this._loadHandlerDelegate = null;
    }
    this._initializing = true;
    this._doInitialize();
}

No comments:

Post a Comment