Compartir a través de


SPAlternateUrl Class

Represents an incoming URL and the zone with which it is associated.

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

Remarks

Use the [P:Microsoft.SharePoint.Administration.SPVirtualServerConfig.][AlternateUrls] property of the SPVirtualServerConfig class or the AlternateUrls property of the SPWebApplication class to return an SPAlternateUrlCollection object that represents the collection of alternate request URLs for a virtual server or Web application. Use an indexer to return a single item from the collection. For example, if the collection is assigned to a variable named myUrls, use myUrls[index] in C# or myUrls(index) in Visual Basic, where index is either the index number of the item in the collection or a string containing the incoming URL of the request.

Examples

The following code example creates a URL for the intranet zone and adds it to the collection of alternate request URLs for the zone.

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.

See Also

Reference

SPAlternateUrl Members

Microsoft.SharePoint.Administration Namespace