Export (0) Print
Expand All

UserControl.Request Property

Gets the Request object for the current Web request.

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

Property Value

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

Example

[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)

[C#] 

     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.

Requirements

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

See Also

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

Show:
© 2014 Microsoft