SPWebConfigModification - Classe

Contient des modifications qui sont apportées au fichier Web.config.

Hiérarchie d’héritage

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

Espace de noms :  Microsoft.SharePoint.Administration
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

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

Remarques

Une collection de modifications web.config est un ensemble de commandes qui, lors du traitement par le manipulateur web.config dans Microsoft SharePoint Foundation, modifiez l'état du fichier web.config. Vous pouvez associer un ensemble de ces commandes pour vous assurer qu'ils appliquent les marqueurs requis et les attributs dans web.config. Chaque modification est exprimée sous la forme d'un objet dans le modèle objet d'administration.

Utilisez la propriété WebConfigModifications de la classe SPWebApplication ou SPWebService pour obtenir la collection des modifications web.config dans l'application Web ou dans toutes les applications Web au service Web. Pour appliquer les modifications que vous définissez via la classe SPWebConfigModification pour les fichiers web.config dans la batterie de serveurs, appelez la méthode ApplyWebConfigModifications sur l'objet service Web contenu actif, comme suit : SPWebService.ContentService.ApplyWebConfigModifications

Exemples

L'exemple suivant ajoute une entrée de contrôle sécurisé à la section contrôles sécurisés dans le fichier web.config dans l'ensemble de la batterie de serveurs.

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

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

SPWebConfigModification - Membres

Microsoft.SharePoint.Administration - Espace de noms