ProviderSettings Class
Assembly: System.Configuration (in system.configuration.dll)
ASP.NET uses providers to perform specific services required by a feature. For example, the membership feature uses a provider to coordinate the persistence of membership data in a database.
In a configuration file, individual providers are added to a providers element within a particular feature section.
The ProviderSettings class represents a particular group of settings that are added to the providers element within a configuration section. Typically the configuration attributes specified by the add directive include a name, type, and other properties.
The following code example shows how to use the ProviderSettings.
using System; using System.Collections; using System.Collections.Specialized; using System.Text; using System.Configuration; namespace Samples.AspNet.Configuration { // Show how to use a custom protected configuration // provider. public class UsingProviderSettings { private static void GetProviderSettings() { // Get the application configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); ProtectedConfigurationSection pSection = config.GetSection("protectedData") as ProtectedConfigurationSection; ProviderSettingsCollection providerSettings = pSection.Providers; foreach (ProviderSettings pSettings in providerSettings) { Console.WriteLine( "Provider settings name: {0", pSettings.Name); Console.WriteLine( "Provider settings type: {0", pSettings.Type); NameValueCollection parameters = pSettings.Parameters; IEnumerator pEnum = parameters.GetEnumerator(); int i = 0; while (pEnum.MoveNext()) { string pLength = parameters[i].Length.ToString(); Console.WriteLine( "Provider ssettings: {0 has {1 parameters", pSettings.Name, pLength); static void Main(string[] args) { GetProviderSettings();
The following is an excerpt of the configuration file used by the above example.
<configProtectedData>
<providers>
<clear />
<add keyContainerName="pcKey.txt"
name="TripleDESProtectedConfigurationProvider"
type="Samples.Aspnet.Configuration.TripleDESProtectedConfigurationProvider, protectedconfigurationproviderlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=79e01ae0f5cfc66f, processorArchitecture=MSIL" />
</providers>
</configProtectedData>
<connectionStrings>
<add name="NorthwindConnectionString"
connectionString="Data Source=webnetue2;Initial Catalog=Northwind;User ID=aspnet_test;Password=test"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.