This documentation is archived and is not being maintained.

SPPrefixCollection Class

Windows SharePoint Services 3

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

When a request to this Web application is received by the Web server, Windows SharePoint Services looks at the URL path of the request to determine whether the request should be handled by Windows SharePoint Services or by IIS. Inclusions specify what URL paths are handled by Windows SharePoint Services. 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 .NET, 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 Windows SharePoint Services. 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.