Export (0) Print
Expand All

SPAlternateUrl Class

Windows SharePoint Services 3

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

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPAlternateUrl

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

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPAlternateUrl : SPAutoSerializingObject

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.

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); 

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft