WebConfigurationManager.AppSettings 속성

정의

웹 사이트의 애플리케이션 설정을 가져옵니다.

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

속성 값

NameValueCollection 현재 웹 애플리케이션의 AppSettingsSection 기본 구성에 대한 개체를 포함하는 개체입니다.

예외

애플리케이션 설정 데이터로 유효한 NameValueCollection 개체를 검색할 수 없습니다.

예제

다음 예제에서는 메서드를 사용하여 구성 정보에 액세스하는 AppSettings 방법을 보여줍니다.


// 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

설명

AppSettingsSection 개체에는 구성 파일의 섹션이 <appSettings> 포함되어 있습니다.

적용 대상

추가 정보