SPPrefixCollection Class

Represents a collection of SPPrefix objects.

Inheritance Hierarchy


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


<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class SPPrefixCollection _
    Inherits SPBaseCollection _
    Implements IEnumerable(Of SPPrefix), IEnumerable
Dim instance As SPPrefixCollection
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPPrefixCollection : SPBaseCollection, 
    IEnumerable<SPPrefix>, IEnumerable


When a request to this Web application is received by the Web server, Microsoft SharePoint Foundation looks at the URL path of the request to determine whether the request should be handled by SharePoint Foundation or by Internet Information Services (IIS). Inclusions specify what URL paths are handled by SharePoint Foundation. It is not necessary to specify the URL paths that are handled by IIS—when the IIS worker process hosting this Web application starts, it scans the home directory of this Web application looking for files, folders, and virtual directories and automatically excludes those it finds so that they will be handled by IIS.

Use Prefixes or Prefixes to return the collection of prefixes for the Web application. To add a prefix, use the Add method.

Use an indexer to return a single prefix from the collection. For example, if the collection is assigned to a variable named myPrefixes, use myPrefixes[index] in C#, or myPrefixes(index) in Visual Basic, where index is the index number of the prefix in the collection.


The following example adds a URL path to the collection of URL paths that will be handled by SharePoint Foundation. This URL path can host multiple site collections below it.

Dim myPrefix As String = "Path"

Dim webApplication As SPWebApplication = _
   SPWebApplication.Lookup(New Uri("http://machinename"))
Dim prefixCollection As SPPrefixCollection = webApplication.Prefixes

If prefixCollection.Contains(myPrefix) = False Then
    prefixCollection.Add(myPrefix, SPPrefixType.WildcardInclusion)
End If
string myPrefix = "Path";

SPWebApplication webApplication = 
   SPWebApplication.Lookup(new Uri("http://machinename"));
SPPrefixCollection prefixCollection = webApplication.Prefixes;

if (prefixCollection.Contains(myPrefix) == false)
    prefixCollection.Add(myPrefix, SPPrefixType.WildcardInclusion);

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


SPPrefixCollection Members

Microsoft.SharePoint.Administration Namespace