WebConfigurationManager.AppSettings Proprietà
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene le impostazioni dell'applicazione del sito Web.
public:
static property System::Collections::Specialized::NameValueCollection ^ AppSettings { System::Collections::Specialized::NameValueCollection ^ get(); };
public static System.Collections.Specialized.NameValueCollection AppSettings { get; }
static member AppSettings : System.Collections.Specialized.NameValueCollection
Public Shared ReadOnly Property AppSettings As NameValueCollection
Oggetto NameValueCollection contenente l'oggetto AppSettingsSection per la configurazione predefinita dell'applicazione Web corrente.
Impossibile recuperare un oggetto NameValueCollection valido con i dati di impostazione dell'applicazione.
Nell'esempio seguente viene illustrato come accedere alle informazioni di configurazione con il AppSettings metodo .
// Show the use of the AppSettings property
// to get the application settings.
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();
}
' Show the use of AppSettings property
' to get the application settings.
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
Un AppSettingsSection oggetto contiene la sezione del file di <appSettings>
configurazione.
Prodotto | Versioni |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Feedback su .NET
.NET è un progetto open source. Seleziona un collegamento per fornire feedback: