ConfigurationAttribute ConfigurationAttribute ConfigurationAttribute ConfigurationAttribute Class

Definition

Represents a single property in a configuration element.

public ref class ConfigurationAttribute
public class ConfigurationAttribute
type ConfigurationAttribute = class
Public Class ConfigurationAttribute
Inheritance
ConfigurationAttributeConfigurationAttributeConfigurationAttributeConfigurationAttribute

Examples

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"));
            }
        }
    }
}

Properties

IsInheritedFromDefaultValue IsInheritedFromDefaultValue IsInheritedFromDefaultValue IsInheritedFromDefaultValue

Gets a value indicating whether the attribute value is the default value.

IsProtected IsProtected IsProtected IsProtected

Gets a value indicating whether the attribute value is encrypted.

Name Name Name Name

Gets the name of the configuration attribute.

Schema Schema Schema Schema

Gets the schema object that is used for the configuration attribute.

Value Value Value Value

Gets the value of the configuration attribute.

Methods

Delete() Delete() Delete() Delete()

Deletes the configuration attribute from the configuration section.

GetMetadata(String) GetMetadata(String) GetMetadata(String) GetMetadata(String)

Gets attribute metadata from the IIS 7 configuration system.

SetMetadata(String, Object) SetMetadata(String, Object) SetMetadata(String, Object) SetMetadata(String, Object)

Sets attribute metadata in the IIS 7 configuration system.

Applies to