SPAlternateUrl Class

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

Inheritance Hierarchy


Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No


<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


Use the 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.


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("", SPUrlZone.Intranet)
System.Uri webApplicationUri = new Uri("http://Server_Name/sites/Site_Name");

SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);
SPAlternateUrlCollection altUrls = webApplication.AlternateUrls;
SPAlternateUrl altUrl = new SPAlternateUrl("", SPUrlZone.Intranet);

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


SPAlternateUrl Members

Microsoft.SharePoint.Administration Namespace