Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.








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 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.


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.


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


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
wRequest.set_userContext("user's context");