This documentation is archived and is not being maintained.

UserControl.Request Property

Gets the Request object for the current Web request.

[Visual Basic]
Public ReadOnly Property Request As HttpRequest
public HttpRequest Request {get;}
public: __property HttpRequest* get_Request();
public function get Request() : HttpRequest;

Property Value

The HttpRequest object associated with the Page that contains the UserControl instance.


[Visual Basic, C#] The following example uses the Request property to obtain the physical path of the user control. With an ID property set to myControl, the user control's location is obtained by a containing page or user control using the myControl.Request.Path syntax.

[Visual Basic] 
myControl.Response.Write("<br><b>The server code is running on machine</b> : " + myControl.Server.MachineName)

Dim actualServerPath As String = myControl.MapPath(myControl.Request.Path)


     myControl.Response.Write("<br><b>The server code is running on machine</b> : " + myControl.Server.MachineName);

     string actualServerPath = myControl.MapPath(myControl.Request.Path);

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

UserControl Class | UserControl Members | System.Web.UI Namespace | HttpRequest | Request