SPWebConfigModification-Klasse

Enthält die Änderungen, die der Datei Web.config vorgenommen werden.

Vererbungshierarchie

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPWebConfigModification

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

Syntax

'Declaration
<GuidAttribute("2BE8CC87-138D-4A5F-96A7-A842D6364FA4")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPWebConfigModification _
    Inherits SPAutoSerializingObject
'Usage
Dim instance As SPWebConfigModification
[GuidAttribute("2BE8CC87-138D-4A5F-96A7-A842D6364FA4")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPWebConfigModification : SPAutoSerializingObject

Hinweise

Eine Auflistung von Änderungen an web.config ist eine Reihe von Befehlen, die, bei der Verarbeitung mit der "Web.config" Manipulator in Microsoft SharePoint Foundationden Zustand der Datei web.config ändern. Sie können eine Reihe von diese Befehle, um sicherzustellen, dass sie die gewünschten Tags und Attribute in der Datei web.config gelten zusammen Zeichenfolge. Jede Änderung wird als ein Objekt in das administrative Objektmodell ausgedrückt.

Verwenden Sie die WebConfigModifications -Eigenschaft der SPWebApplication oder SPWebService -Klasse, um die Auflistung der "Web.config" Änderungen in der Webanwendung oder in allen Webanwendungen innerhalb des Webdienstes abzurufen. Zum Anwenden der Änderungen, die Sie über die SPWebConfigModification -Klasse in der web.config-Dateien in der Serverfarm zu definieren, rufen Sie die ApplyWebConfigModifications -Methode auf das aktuelle Content Webdienstobjekt, wie folgt: SPWebService.ContentService.ApplyWebConfigModifications

Beispiele

Im folgenden Beispiel wird im Abschnitt Sichere Steuerelemente in der Datei web.config in der gesamten Serverfarm einen Eintrag für sichere Steuerelemente hinzugefügt.

Dim myService As SPWebService = SPWebService.ContentService
         
Dim myModification As New SPWebConfigModification()
myModification.Path = "configuration/SharePoint/SafeControls"
myModification.Name = "SafeControl[@Assembly='MyCustomAssembly'][@Namespace='MyCustomNamespace'][@TypeName='*'][@Safe='True']"
myModification.Sequence = 0
myModification.Owner = WebConfigModificationFeatureReceiver.OwnerId
myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
myModification.Value = "<SafeControl Assembly='MyCustomAssembly' Namespace='MyCustomNamespace' TypeName='*' Safe='True' />"
         
myService.WebConfigModifications.Add(myModification)
myService.Update()
myService.ApplyWebConfigModifications()
SPWebService myService = SPWebService.ContentService;

SPWebConfigModification myModification = new SPWebConfigModification();
myModification.Path = "configuration/SharePoint/SafeControls";
myModification.Name = "SafeControl[@Assembly='MyCustomAssembly'][@Namespace='MyCustomNamespace'][@TypeName='*'][@Safe='True']";
myModification.Sequence = 0;
myModification.Owner = WebConfigModificationFeatureReceiver.OwnerId;
myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
myModification.Value = "<SafeControl Assembly='MyCustomAssembly' Namespace='MyCustomNamespace' TypeName='*' Safe='True' />";

myService.WebConfigModifications.Add(myModification);
myService.Update(); 
myService.ApplyWebConfigModifications();

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.

Siehe auch

Referenz

SPWebConfigModification-Member

Microsoft.SharePoint.Administration-Namespace