Aggiornamento: novembre 2007
Ottiene i dati dell'oggetto AppSettingsSection per la configurazione predefinita dell'applicazione Web corrente.
Spazio dei nomi:
System.Web.Configuration Assembly:
System.Web (in System.Web.dll)
Visual Basic - (Dichiarazione)
Public Shared ReadOnly Property AppSettings As NameValueCollection
Dim value As NameValueCollection
value = WebConfigurationManager.AppSettings
public static NameValueCollection AppSettings { get; }
public:
static property NameValueCollection^ AppSettings {
NameValueCollection^ get ();
}
/** @property */
public static NameValueCollection get_AppSettings()
public static function get AppSettings () : NameValueCollection
Oggetto AppSettingsSection contenente la sezione <appSettings> del file di configurazione.
Nell'esempio riportato di seguito viene illustrato come accedere alle informazioni sulla configurazione con il metodo AppSettings.
' Show the use of AppSettings.
' It gets the section from the configuration
' file located at the application current level.
Shared Sub GetAppSettings()
' Get the appSettings key,value pairs collection.
Dim appSettings As NameValueCollection = _
WebConfigurationManager.AppSettings
' Get the collection enumerator.
Dim appSettingsEnum As IEnumerator = _
appSettings.GetEnumerator()
' Loop through the collection and
' display the appSettings key, value pairs.
Dim i As Integer = 0
Console.WriteLine("[Display appSettings]")
While appSettingsEnum.MoveNext()
Dim key As String = appSettings.AllKeys(i)
Console.WriteLine("Key: {0} Value: {1}", _
key, appSettings(key))
i += 1
End While
Console.WriteLine()
End Sub 'GetAppSettings
// Show the use of AppSettings.
// It gets the section from the configuration
// file located at the application current level.
static void GetAppSettings()
{
// Get the appSettings key,value pairs collection.
NameValueCollection appSettings =
WebConfigurationManager.AppSettings
as NameValueCollection;
// Get the collection enumerator.
IEnumerator appSettingsEnum =
appSettings.GetEnumerator();
// Loop through the collection and
// display the appSettings key, value pairs.
int i = 0;
Console.WriteLine("[Display appSettings]");
while (appSettingsEnum.MoveNext())
{
string key = appSettings.AllKeys[i].ToString();
Console.WriteLine("Key: {0} Value: {1}",
key, appSettings[key]);
i += 1;
}
Console.WriteLine();
}
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition , Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Informazioni sulla versione
.NET Framework
Supportato in: 3.5, 3.0, 2.0
Riferimenti
Altre risorse