SPSite.HostName 属性

Gets the name of the server that hosts the site collection.

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public ReadOnly Property HostName As String
    Get
用法
Dim instance As SPSite
Dim value As String

value = instance.HostName
public string HostName { get; }

属性值

类型:System.String
A string that contains the name of the host.

备注

When used in conjunction with an SPSite constructor, the HostName property contains a different value depending on the URL that is passed to the constructor. For example, if "http://" + System.Environment.MachineName is passed as the URL, the HostName property contains the name of the computer that is running SharePoint Foundation, but if https://localhost is passed as the URL, then the property contains "localhost".

示例

The following code example displays the host name for the current site collection.

Dim oSiteCollection As SPSite = SPContext.Current.Site
Response.Write(oSiteCollection.HostName)
SPSite oSiteCollection = SPContext.Current.Site;
Response.Write(oSiteCollection.HostName);

另请参阅

引用

SPSite 类

SPSite 成员

Microsoft.SharePoint 命名空间