Sys.Net.WebRequest executor Property
Gets or sets the executor of the associated Sys.Net.WebRequest instance.
Note
To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.
var executor = MyWebRequest.get_executor();
myRequest.set_Executor(value);
Parameters
Parameter |
Description |
---|---|
value |
An instance of a class that is derived from Sys.Net.WebRequestExecutor. |
Return Value
The current WebRequestExecutor instance.
Exceptions
Exception type |
Condition |
---|---|
value cannot be null. |
|
The executor was set after it was enabled. |
|
value is not a valid WebRequestExecutor type. |
Remarks
After the WebRequest instance has finished executing, the executor property returns the active network executor associated with the request. You can programmatically access the WebRequest instance from the associated executor.
You set the executor property only if you need a custom network executor. If you do not set this property, the system uses the default Sys.Net.XmlHttpExecutor executor, which is set after the invoke method is called.
You cannot set the executor property if the WebRequest instance already has an associated executor and the Web request has already been issued. If you try to set the executor property by using an executor that is already associated with the request instance, such as myRequest.set_executor(myRequest.get_executor()), an exception is thrown.
Example
The following example shows how to set the executor. This code is part of a complete example found in the WebRequest class overview.
// This function sets the Web request
// executor, replacing the default one.
function WebRequestExecutor()
{
// Instantiate the WebRequest.
var wRequest = new Sys.Net.WebRequest();
// Create the executor. In this case it is an
// XMLHttpExecutor, equivalent to the default
// executor. But, you can create a custom one.
var executor = new Sys.Net.XMLHttpExecutor();
// Set the executor, replacing the default one.
// In this case the executor is equivalent to the
// default one.
wRequest.set_executor(executor);
// Get the current executor
var executor =
wRequest.get_executor();
alert("Response availabe: " + executor.get_responseAvailable())
}
See Also
Reference
Sys.Net.WebRequestManager Class