SPAlternateUrl class
代表傳入 URL,而與它相關聯的區域。
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPAlternateUrl
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPAlternateUrl _
Inherits SPAutoSerializingObject
'用途
Dim instance As SPAlternateUrl
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPAlternateUrl : SPAutoSerializingObject
備註
您可以使用SPVirtualServerConfig類別之AlternateUrls屬性或SPWebApplication類別之AlternateUrls屬性可傳回SPAlternateUrlCollection物件,代表虛擬伺服器或 Web 應用程式的備用要求 Url 的集合。若要從集合中傳回單一項目使用索引器。例如,若集合已指派給變數myUrls,使用myUrls[index]以 C# 或 Visual Basic,其中index是集合中項目的索引編號,或是包含傳入的要求 URL 的字串中的myUrls(index) 。
Examples
下列程式碼範例會建立內部網路區域的 URL,並將其新增至區域的備用要求 Url 的集合。
Dim webApplicationUri = New Uri("http://Server_Name/sites/Site_Name")
Dim webApplication As SPWebApplication = SPWebApplication.Lookup(webApplicationUri)
Dim altUrls As SPAlternateUrlCollection = webApplication.AlternateUrls
Dim altUrl As New SPAlternateUrl("http://Server_Incoming.internal.example.com", SPUrlZone.Intranet)
altUrls.Add(altUrl)
System.Uri webApplicationUri = new Uri("http://Server_Name/sites/Site_Name");
SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);
SPAlternateUrlCollection altUrls = webApplication.AlternateUrls;
SPAlternateUrl altUrl = new SPAlternateUrl("http://Server_Incoming.internal.example.com", SPUrlZone.Intranet);
altUrls.Add(altUrl);
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.