Sys.Net.WebRequestExecutor abort Method

Stops the pending network request issued by the executor.

MyExecutor.abort();

Remarks

The specifics of aborting a request vary depending on how an executor is implemented. However, all executors that derive from WebRequestExecutor must set their state to aborted and must raise the completed event of the associated Sys.Net.WebRequest object.

Note

The executor properties do not contain consistent data after abort has been called.

Example

The following example shows how to abort a request using the default Sys.Net.XMLHttpExecutor class.

// This function aborts a Web request.
function AbortWebRequest()
{
    // Create the WebRequest object.
    wRequest =  new Sys.Net.WebRequest();

    // Set the request Url.  
    wRequest.set_url("getTarget.htm");

   // Clear the results area.
    resultElementId.innerHTML = "";

    // Set the Completed event handler, 
    // for processing return data
    wRequest.add_completed(OnCompleted);

    // Make the request.
    wRequest.invoke();

    // Get the current executor.
    var executor = wRequest.get_executor();


    // Abort the request.
    executor.abort();

    // Check if the executor is aborted.
    var execAborted = 
        executor.get_aborted();

    alert("Executor aborted: " + execAborted);
}

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequest Class

Sys.Net.XMLHttpExecutor Class