ConfigurationAttribute Class
IIS 7.0
Represents a single property in a configuration element.
Namespace:
Microsoft.Web.Administration
Assembly: Microsoft.Web.Administration (in Microsoft.Web.Administration.dll)
The ConfigurationAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
|
IsInheritedFromDefaultValue | Gets a value indicating whether the attribute value is the default value. |
|
IsProtected | Gets a value indicating whether the attribute value is encrypted. |
|
Name | Gets the name of the configuration attribute. |
|
Schema | Gets the schema object that is used for the configuration attribute. |
|
Value | Gets the value of the configuration attribute. |
| Name | Description | |
|---|---|---|
|
Delete | Deletes the configuration attribute from the configuration section. |
|
Equals | (Inherited from Object.) |
|
Finalize | (Inherited from Object.) |
|
GetHashCode | (Inherited from Object.) |
|
GetMetadata | Gets attribute metadata from the IIS 7 configuration system. |
|
GetType | (Inherited from Object.) |
|
MemberwiseClone | (Inherited from Object.) |
|
SetMetadata | Sets attribute metadata in the IIS 7 configuration system. |
|
ToString | (Inherited from Object.) |
The following example displays a few property values for the ConfigurationAttribute object. The example sets the metadata, commits the changes to the ApplicationHost.config file, and then gets the metadata.
using System; using System.Collections.Generic; using System.Text; using Microsoft.Web.Administration; using Microsoft.Web.Management; namespace AdministrationSnippets { public class SnippetConfigurationAttribute { public void GetConfigurationAttribute() { ServerManager manager = new ServerManager(); Configuration config = manager.GetApplicationHostConfiguration(); ConfigurationSection configSection = config.GetSection("system.web/anonymousIdentification"); ConfigurationAttributeCollection configAttributeCollection = configSection.Attributes; ConfigurationAttribute attribute = configAttributeCollection[1]; // Use any of the following encryption providers. // attribute.SetMetadata("encryptionProvider", "IISWASOnlyRsaProvider"); // attribute.SetMetadata("encryptionProvider", "AesProvider"); attribute.SetMetadata("encryptionProvider", "IISWASOnlyAesProvider"); // Commit the changes to applicationHost.config manager.CommitChanges(); // Get the attributes again, after the commit changes. Configuration config2 = manager.GetApplicationHostConfiguration(); configSection = config2.GetSection("system.web/anonymousIdentification"); configAttributeCollection = configSection.Attributes; Console.WriteLine("There are " + configAttributeCollection.Count.ToString() + " Configuration attributes."); attribute = configAttributeCollection[1]; Console.WriteLine("metadata: " + attribute.GetMetadata("encryptionProvider")); // Display each configuration attribute with properties and metadata. foreach (ConfigurationAttribute configAttribute in configAttributeCollection) { Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", configAttribute.Name, configAttribute.Value, configAttribute.IsProtected, configAttribute.GetMetadata("encryptionProvider")); } } } }