SPHttpThrottleSettings.AddThrottleClassifier Method
Adds an HTTP request classifier to the ThrottleClassifiers collection of the SPHttpThrottleSettings object.
Namespace: Microsoft.SharePoint.Utilities
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
Public Sub AddThrottleClassifier ( _
classifier As SPRequestThrottleClassifier _
)
'Usage
Dim instance As SPHttpThrottleSettings
Dim classifier As SPRequestThrottleClassifier
instance.AddThrottleClassifier(classifier)
public void AddThrottleClassifier(
SPRequestThrottleClassifier classifier
)
Parameters
classifier
Type: Microsoft.SharePoint.Utilities.SPRequestThrottleClassifierThe classifier that is added.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | classifier is a null reference (Nothing in Visual Basic). |
ArgumentException | classifier is already in the collection. |
Examples
The following sample code shows the method in use. For the full example, see How to: Create and Register or Deregister a Request Classifier.
// Get a reference to the throttle settings
Uri webApplicationUri = new Uri("Http://localhost/");
SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);
SPHttpThrottleSettings throttleSettings = SPHttpThrottleSettings.GetHttpThrottleSettings(webApplication);
// Create the classifier object
SPHttpFileExtensionThrottleClassifier docxClassifier = new SPHttpFileExtensionThrottleClassifier(".docx",SPRequestThrottleLevel.FirstStage);
// Add it to the collection of classifiers
throttleSettings.AddThrottleClassifier(docxClassifier);
' Get a reference to the throttle settings
Dim webApplicationUri As New Uri("Http://localhost/")
Dim webApplication As SPWebApplication = SPWebApplication.Lookup(webApplicationUri)
Dim throttleSettings As SPHttpThrottleSettings = SPHttpThrottleSettings.GetHttpThrottleSettings(webApplication)
' Create the classifier object
Dim docxClassifier As New SPHttpFileExtensionThrottleClassifier(".docx",SPRequestThrottleLevel.FirstStage)
' Add it to the collection of classifiers
throttleSettings.AddThrottleClassifier(docxClassifier)