Share via


Sys.Net.WebRequestManager add_invokingRequest Method

Registers a handler for processing the invoking request event of the WebRequestManager.

Sys.Net.WebRequestManager.add_invokingRequest(handler);

Parameters

Parameter

Description

handler

The function registered to handle the invoking request event.

Remarks

Use the add_invokingRequest method to set a function that the WebRequestManager class must call before it routes the Web request to the executor. This event enables you to inspect the Web requests directed to the WebRequestManager. You can use this event to perform the following tasks:

  • Audit outgoing network requests.

  • Intercept Web requests and selectively cancel them.

  • Process Web requests by using custom logic instead of the executor construct. For example, you can set a local storage service to intercept every request and create response data from a local store instead of letting requests flow across the network.

Your event handler must have the following signature:

function OnInvokingRequest(sender, networkRequestEventArgs){} 

The sender parameter is set to the WebRequestManager instance.

Example

The following example shows how to add an event to be issued before the Web request is executed. This code is part of a complete example found in the WebRequestManager class overview.

// Set the handler to call before the Web request
// is executed.
Sys.Net.WebRequestManager.add_invokingRequest(On_InvokingRequest);   

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequestExecutor Class

Sys.Net.XMLHttpExecutor Class