This documentation is archived and is not being maintained.

UserControl.Server Property

Gets the Server object for the current Web request.

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

Property Value

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


The Server object is compatible with ASP pages.


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


     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 | HttpServerUtility | Server