共用方式為


SPWebConfigModification class

包含對 web.config 所做的修改。

Inheritance hierarchy

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

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

Syntax

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

備註

一群 web.config 修改是一組命令的、 時處理 web.config manipulator Microsoft SharePoint Foundation中,變更 web.config 檔案中的狀態。您可以搭配字串一組的下列命令,以確保它們套用的所需的標籤和 web.config 內的屬性。每個修改以表示系統管理物件模型中的物件。

若要取得之 web.config 修改集合中的 Web 應用程式或 Web 服務內的所有 Web 應用程式中使用SPWebApplicationSPWebService類別的WebConfigModifications屬性。若要套用到伺服器陣列中的 web.config 檔案SPWebConfigModification類別所定義的修改,請呼叫ApplyWebConfigModifications方法在目前內容的 Web 服務物件,,如下所示: SPWebService.ContentService.ApplyWebConfigModifications

Examples

下列範例會將安全控制項項目新增至安全的控制項] 區段中,在整個伺服器陣列中的 web.config。

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

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.

請參閱

參照

SPWebConfigModification members

Microsoft.SharePoint.Administration namespace