UserControl.Server Property

Definition

Gets the HttpServerUtility object for the current Web request.

C#
[System.ComponentModel.Browsable(false)]
public System.Web.HttpServerUtility Server { get; }

Property Value

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

Attributes

Examples

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.

C#

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

Remarks

The Server object is compatible with ASP pages.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also