Share via


SPIisWebSite.ServerComment property

Gets or sets the display name of the Internet Information Services (IIS) Web site.

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

Syntax

'Declaration
Public Property ServerComment As String
    Get
    Set
'Usage
Dim instance As SPIisWebSite
Dim value As String

value = instance.ServerComment

instance.ServerComment = value
public string ServerComment { get; set; }

Property value

Type: System.String
A string that contains the display name of the IIS Web site.

Remarks

This string in the configuration store for the IIS Web site must match the description for the Web application as specified with the SPWebApplicationBuilder object, as well as with the SPIisSettings object.

If a site already exists with this value in this property, a new site can still be created using this value because the site identification number is the property that makes the site unique.

Examples

The following code example displays the current server name, then allows the user at the console to enter a new server name. A new instance of the SPIisWebSite is instantiated with the same instance ID so that the server name change can be verified without stopping and restarting the IIS service.

[C#]

SPSite oSiteCollection = new SPSite("https://localhost");
string strNewName;
Uri uri = new Uri(oSiteCollection.Url); 
SPWebApplication webApp = SPWebApplication.Lookup(uri);
int instID = webApp.IisSettings[SPUrlZone.Default].PreferredInstanceId;
SPIisWebSite iisWebSite = new SPIisWebSite(instID);

Console.WriteLine("*> SPIISWebsite Instance Id " + iisWebSite.InstanceId);
Console.WriteLine("*> Server Comment           " + iisWebSite.ServerComment);
Console.Write("Input Server Name: ");
strNewName = Console.ReadLine();

iisWebSite.ServerComment = strNewName;
iisWebSite.Update();

SPIisWebSite iisWebSite2 = new SPIisWebSite(instID);
Console.WriteLine("*> New Server Comment      " + iisWebSite2.ServerComment);
iisWebSite2.Provision();

See also

Reference

SPIisWebSite class

SPIisWebSite members

Microsoft.SharePoint.Administration namespace