Clase SPWebConfigModification

Contiene las modificaciones realizadas en el archivo web.config.

Jerarquía de la herencia

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

Espacio de nombres:  Microsoft.SharePoint.Administration
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

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

Comentarios

Una colección de las modificaciones de web.config es un conjunto de comandos que, cuando procesa el manipulador de web.config en Microsoft SharePoint Foundation, cambie el estado del archivo web.config. Puede encadenar un conjunto de estos comandos para garantizar que se apliquen las etiquetas deseadas y atributos en el archivo web.config. Cada modificación se expresa como un objeto en el modelo de objetos administrativos.

Utilice la propiedad WebConfigModifications de la clase SPWebApplication o SPWebService para obtener la colección de las modificaciones de web.config en la aplicación Web o en todas las aplicaciones Web dentro del servicio Web. Para aplicar las modificaciones que se definen mediante la clase SPWebConfigModification en los archivos web.config en la granja de servidores, llame al método ApplyWebConfigModifications en el objeto contenido de servicio Web actual, como se indica a continuación: SPWebService.ContentService.ApplyWebConfigModifications

Ejemplos

En el siguiente ejemplo se agrega una entrada de control seguro a la sección de controles seguros en el archivo web.config en toda la granja de servidores.

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

Seguridad para subprocesos

Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.

Vea también

Referencia

Miembros SPWebConfigModification

Espacio de nombres Microsoft.SharePoint.Administration