Share via


Sys.Net.WebRequestManager defaultTimeout Property

Gets or sets the time-out for the default network executor.

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 dTimeout = Sys.Net.WebRequestManager.get_defaultTimeout ();
Sys.Net.WebRequestManager.set_defaultTimeout(value);

Parameters

Parameter

Description

value

The time in milliseconds that the default executor should wait before timing out a Web request. This value must be 0 or a positive integer.

Return Value

An integer value that indicates the current time-out for the default executor.

Exceptions

Exception type

Condition

Sys.ArgumentOutOfRangeException

An invalid parameter was passed.

Remarks

Use the defaultTimeout property to get or set the time in milliseconds that the default executor should wait before timing out a Web request.

By setting a time-out value that is not zero, you can make sure that a pending Web request returns the control back to the caller in a timely manner.

Example

The following example shows how to set and get the default executor time-out. This code is part of a complete example found in the WebRequestManager class overview.

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

    // Get system default timeout.
    var sysDefaultTimeout = 
        Sys.Net.WebRequestManager.get_defaultTimeout();

    alert("Get default timeout: " + sysDefaultTimeout);


    // Set custom default timeout.
    Sys.Net.WebRequestManager.set_defaultTimeout(100);

    var customDefaultTimeout = 
        Sys.Net.WebRequestManager.get_defaultTimeout();

    alert("Set default timeout: " + customDefaultTimeout);


    // Set the timeout back to the system default. 
    Sys.Net.WebRequestManager.set_defaultTimeout(
    sysDefaultTimeout);    

}

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequestExecutor Class

Sys.Net.XMLHttpExecutor Class

Other Resources

Language Reference