Sys.Net.WebRequest userContext Property

Gets or sets the user context associated with the 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 userContext = MyWebRequest.get_userContext();
MyWebRequest.set_userContext(value);

Parameters

Parameter

Description

Value

The user context information that is associated with the request. value can be null or any primitive type or JavaScript object.

Return Value

The current Web request user context.

Remarks

The userContext property can be set on the WebRequest instance before calling its invoke method. The same userContext property can be accessed within the completed handler of the Web request. This allows differentiating the event handler callers, or to recover state or context when processing the returned data.

Note

To obtain the userContext from within the event handler, use the userContext of the Sys.Net.WebRequestExecutor webRequest Property.

Example

The following example shows how to set the user context for the Web request. This code is part of a complete example found in the WebRequest class overview.

See Also

Reference

Sys.Net.WebRequestManager Class

Sys.Net.WebRequestExecutor Class

Sys.Net.XMLHttpExecutor Class