Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

UserControl.Server Property

Gets the Server object for the current Web request.

[Visual Basic]
Public ReadOnly Property Server As HttpServerUtility
[C#]
public HttpServerUtility Server {get;}
[C++]
public: __property HttpServerUtility* get_Server();
[JScript]
public function get Server() : HttpServerUtility;

Property Value

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

Remarks

The Server object is compatible with ASP pages.

Example

[Visual Basic, C#] The following example uses the Server property to write the name of the Web server computer on which the user control is running. The myControl.Response.Write syntax instructs the user control to display the information the control obtains with the myControl.Server.Machinename 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 | HttpServerUtility | Server

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.