Sys.Net.WebRequestManager defaultExecutor 属性

更新:2007 年 11 月

获取或设置用于生成网络请求的默认网络执行器类型。

说明:

若要获取或设置客户端 API 属性的属性值,必须调用以 get_set_ 为名称前缀的属性访问器方法。例如,若要获取或设置属性 cancel 的值,需要调用 get_cancel 或 set_cancel 方法。

var dExecutor = Sys.WebRequestManager.get_defaultExecutorType ();
Sys.Net.WebRequestManager.set_defaultExecutorType(value);

参数

参数

说明

value

一个对 WebRequestExecutor 类的实现的引用。

异常

异常类型

条件

Sys.ArgumentException

传递了一个无效参数。

返回值

表示默认 Web 请求执行器的对象。

备注

使用 defaultExecutor 属性可以获取或设置默认执行器,它是对当前 WebRequestExecutor 对象的引用。

WebRequestExecutor 对象准备好将 Web 请求发送到执行器时,它将使用您提供的请求执行器。如果您没有提供执行器,则 WebRequestExecutor 会创建 XmlHttpExecutor 类的一个实例。

示例

下面的示例演示如何使用 defaultExecutorType 属性获取和设置默认执行器。此代码摘自 WebRequestManager 类概述中的一个完整示例。

// Gets and sets the default executor.
function DefaultExecutor()
{
    // Clear the previous results. 
    resultElement.innerHTML = "";

    // Get system default executor type.
    var sysDefaultExecutor = 
        Sys.Net.WebRequestManager.get_defaultExecutorType();
    alert("Get default executor:" + sysDefaultExecutor);


    // Modify the default executor type.
    Sys.Net.WebRequestManager.set_defaultExecutorType(
    "Sys.Net.CustomExecutor");

    var customDefaultExecutor = 
        Sys.Net.WebRequestManager.get_defaultExecutorType();

    alert("Set default executor: " + customDefaultExecutor);

    // Set the executor back to the system default. This is 
    // to allow the WebRequest script to run.
    executor = "Sys.Net.XMLHttpExecutor";
    Sys.Net.WebRequestManager.set_defaultExecutorType(
    sysDefaultExecutor);    

}

请参见

参考

Sys.Net.WebRequestManager 类

Sys.Net.WebRequestExecutor 类

Sys.Net.XMLHttpExecutor 类