This documentation is archived and is not being maintained.

SPWebServer Class

Windows SharePoint Services 3

Represents a front-end Web server in a server farm.

System.Object
  Microsoft.SharePoint.Administration.SPWebServer

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPWebServer

Use the WebServers property of the SPGlobalConfig class to get the collection of Web servers in a server farm. Use an indexer to return a single Web server from the collection. For example, if the collection is assigned to a variable named myWebServers, use myWebServers[index] in C#, or myWebServers(index) in Visual Basic, where index is the index number of the server in the collection.

The following code example displays information in a console application about all the front-end Web servers in the Windows SharePoint Services deployment.

SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPGlobalConfig globalConfig = globalAdmin.Config;

SPWebServerCollection webServers = globalConfig.WebServers;

foreach (SPWebServer webServer in webServers)
{
    Console.Write("Name: " + webServer.Name +
        "\nAddress: " + webServer.Address +
        "\nPort: " + webServer.AdminPort.ToString() +
        "\nAdmin Port URL: " + webServer.AdminPortUrl +
        "\nID: " + webServer.Id.ToString() + "\n\n");
}

Console.ReadLine();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: