WebConfigurationManager.AppSettings Property
.NET Framework (current version)
Gets the Web site's application settings.
Assembly: System.Web (in System.Web.dll)
Property Value
Type: System.Collections.Specialized.NameValueCollectionA NameValueCollection object that contains the AppSettingsSection object for the current Web application's default configuration.
| Exception | Condition |
|---|---|
| ConfigurationErrorsException | A valid NameValueCollection object could not be retrieved with the application settings data. |
An AppSettingsSection object contains the configuration file's <appSettings> section.
The following example shows how to access configuration information with the AppSettings method.
' 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 'GetAppSettings
.NET Framework
Available since 2.0
Available since 2.0
Show: