SPWebConfigModification.Sequence Property
Gets or sets the sequence number of the modification.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Property Value
Type: System.UInt32A 32-bit unsigned integer between 0 and 65536. This property throws an InvalidOperationException if the number is outside this range.
Defining the order of nodes
As you can see on this page, the sequence property is only being used when multiple nodes of the exact same type are being added. The default behavior when adding multiple SPWebConfigModification nodes is that they will be placed alphabetically inside web.config. There is a way to keep in control of the ordering. It is described in this blogpost:
http://stephenkaye.blogspot.com/2008/07/master-webconfigmodifications.html
Basically all there is to it is to add the proper sequence to the XPath expression, i.e.:
var mod = new SPWebConfigModification
{
Name = "filter",
Path = "configuration/system.web/browserCaps[2=2]",
Owner = WebConfigModificationOwner,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
Value = "<filter>isMobileDevice=false</filter>"
};
webApp.WebConfigModifications.Add(mod);
This will place this node as the second node within configuration/system.web/browserCaps. Use [1=1] for the first node, [2=2] for the second, [3=3] for the third, etcetera.
http://stephenkaye.blogspot.com/2008/07/master-webconfigmodifications.html
Basically all there is to it is to add the proper sequence to the XPath expression, i.e.:
var mod = new SPWebConfigModification
{
Name = "filter",
Path = "configuration/system.web/browserCaps[2=2]",
Owner = WebConfigModificationOwner,
Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode,
Value = "<filter>isMobileDevice=false</filter>"
};
webApp.WebConfigModifications.Add(mod);
This will place this node as the second node within configuration/system.web/browserCaps. Use [1=1] for the first node, [2=2] for the second, [3=3] for the third, etcetera.
- 9/20/2010
- Koen Zomers
