SPAlternateUrl Class
Represents an incoming URL and the zone with which it is associated.
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPAlternateUrl
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
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("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);