views:

1630

answers:

2

In my webapp, I have a list of links generated from code-behind and bound to a repeater control. Clicking on a link opens a popup window, where, along with displaying some data, an asynchronous call to a WCF Service is made (through a javascript proxy). This service in turn calls another third party web service that might take a long time to respond. I am working with IE6, thats a unavoidable requirement.

Now, I abort this service on onunload if the user decides to not wait for the call to complete and just closes the popup window. The problem is, if the user clicks another link from the repeater immediately after, the new popup window opens but doesn't load the page (doesn't go to the supplied URL) till the previous asynchronous call has completed (I have verified this through Fiddler). Interestingly, this only happens for links within the same domain. If I change the link for one of the popus to, say, www.google.com, then the window opens and goes to the correct url as intended. But, for popups with links within my own domain, which are opened immediately after a popup window with an unfinished request was closed, it waits till the previous request completes before loading the url.

I have verified the correct way to abort a callback and abort does fire properly. I also know that I can only abort my client side call, and not the server side call and I don't care about it. My only requirement is that the browser load the next link regardless of the previous asynchronous response.

//Method to Call Service:

    function GetData(Id) {

            //call the service

            Sys.Net.WebRequestManager.add_invokingRequest(On_InvokingRequest);

            var service = new WrapperService();
            service.GetData(Id, handleSuccess, handleError, null);

            Sys.Net.WebRequestManager.remove_invokingRequest(On_InvokingRequest);
        }

//method to get the current requests abort executor
function On_InvokingRequest(executor, eventArgs) {
        var currentRequest = eventArgs.get_webRequest();
        abortExecutor = currentRequest.get_executor();
    }

//abort service on unload
function unload() {
        if (abortExecutor != null) {
            abortExecutor.abort();
        }
    }

Helpful/Similar links for the background:

browser-waits-for-ajax-call-to-complete-even-after-abort-has-been-called-jquery aborting-an-asp-net-web-service-asynchronous-call canceling-ajax-web-service-call

Anybody faced this before? Its driving me nuts! Any help will be greatly appreciated.

A: 

The answer in one of your links sounds like the problem to me: http://stackoverflow.com/questions/941889/browser-waits-for-ajax-call-to-complete-even-after-abort-has-been-called-jquery

Does your service require session state?

You could prove whether the problem is that IE itself won't issue the request by configuring IE to allow for more than 2 requests to the same domain. If it's being blocked because the aborted request is somehow eating up one of those connections, then increasing it should yield different results. If it still has the problem, it must be that the server is waiting to respond.

Configure IE for more than 2 requests: http://support.microsoft.com/kb/282402

Quote from one of the SO questions you linked:

It turns out I was completely wrong about this being a browser issue - the problem was on the server. ASP.NET serializes requests of the same session that require session state, so in this case, the next page didn't begin processing on the server until those ajax-initiated requests completed.

Unfortunately, in this case, session state is required in the http handler that responded to the ajax calls. But read-only access is good enough, so by marking the handler with IReadOnlySessionState instead of IRequiresSessionState, session locks are not held and the problem is fixed.

InfinitiesLoop
+1  A: 

Can you provide the code snippet where and how did u mark the IReadOnlySessionState attribute? I also have the same problem in the website that I am working on. I call a webservice from my web app, and the webservice in turn calls some external DB service. That DB service may not return before quite some time has elapsed so we put a time out between my website and the webservice so that at least the webservice will timeout and the client end user shall become free after 10 seconds. But if the user does not wait till 10 seconds and gives another request to the webservice then the waiting time of the user increases from 10 seconds to 20 seconds.