次の方法で共有


SPPrefixCollection Class

Represents a collection of SPPrefix objects.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.SPBaseCollection
      Microsoft.SharePoint.Administration.SPPrefixCollection

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

Syntax

<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPPrefixCollection _
    Inherits SPBaseCollection

Dim instance As SPPrefixCollection
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPPrefixCollection : SPBaseCollection

Remarks

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.

Examples

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.

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

Reference

SPPrefixCollection Members

Microsoft.SharePoint.Administration Namespace