SPPrefixCollection class

Represents a collection of SPPrefix objects.

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

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, 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.

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

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