Sys.Net.WebRequest userContext Property
Gets or sets the user context associated with the Sys.Net.WebRequest instance.
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();
The current Web request user context.
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.
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.
// Set user's context