WebConfigurationManager.OpenWebConfiguration 메서드

정의

웹 응용 프로그램 구성 파일을 Configuration 개체로 엽니다.

오버로드

OpenWebConfiguration(String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

OpenWebConfiguration(String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로 및 사이트 이름을 사용하여 읽기 또는 쓰기 작업을 허용합니다.

OpenWebConfiguration(String, String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름 및 위치를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

OpenWebConfiguration(String, String, String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름, 위치 및 서버를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

OpenWebConfiguration(String, String, String, String, IntPtr)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름, 위치, 서버 및 보안 컨텍스트를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

OpenWebConfiguration(String, String, String, String, String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름, 위치, 서버 및 보안 컨텍스트를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

OpenWebConfiguration(String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

public:
 static System::Configuration::Configuration ^ OpenWebConfiguration(System::String ^ path);
public static System.Configuration.Configuration OpenWebConfiguration (string path);
static member OpenWebConfiguration : string -> System.Configuration.Configuration
Public Shared Function OpenWebConfiguration (path As String) As Configuration

매개 변수

path
String

구성 파일의 가상 경로입니다. null인 경우 루트 Web.config 파일이 열립니다.

반환

Configuration

Configuration 개체입니다.

예외

올바른 구성 파일을 로드할 수 없는 경우

예제

다음 예제에서는 사용 하 여 구성 정보에 액세스 하는 방법의 OpenWebConfiguration 메서드.


// Show how to use OpenWebConfiguration(string).
// It gets he appSettings section of a Web application 
// runnig on the local server. 
static void OpenWebConfiguration1()
{
    // Get the configuration object for a Web application
    // running on the local server. 
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenWebConfiguration("/configTest") 
        as System.Configuration.Configuration; 

    // Get the appSettings.
    KeyValueConfigurationCollection appSettings =
         config.AppSettings.Settings;

    // Loop through the collection and
    // display the appSettings key, value pairs.
    Console.WriteLine("[appSettings for app at: {0}]", "/configTest");
    foreach (string key in appSettings.AllKeys)
    {
        Console.WriteLine("Name: {0} Value: {1}",
        key, appSettings[key].Value);
    }

    Console.WriteLine();
}
' Show how to use OpenWebConfiguration(string).
' It gets he appSettings section of a Web application 
' runnig on the local server. 
Shared Sub OpenWebConfiguration1()
   ' Get the configuration object for a Web application
   ' running on the local server. 
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenWebConfiguration("/configTest")
   
   ' Get the appSettings.
     Dim appSettings As KeyValueConfigurationCollection = _
     config.AppSettings.Settings
   
   
   ' Loop through the collection and
   ' display the appSettings key, value pairs.
   Console.WriteLine("[appSettings for app at: {0}]", "/configTest")
   Dim key As String
   For Each key In  appSettings.AllKeys
         Console.WriteLine("Name: {0} Value: {1}", _
         key, appSettings(key).Value)
   Next key
   
   Console.WriteLine()
End Sub

설명

가져올는 Configuration 개체는 리소스에 대 한 코드 설정을 상속 하는 모든 구성 파일에 대 한 권한이 읽기 있어야 합니다. 구성 파일을 업데이트 하려면 구성 파일 및 존재 하는 디렉터리에 대 한 쓰기 권한이 또한으로 코드에 있어야 합니다.

추가 정보

적용 대상

OpenWebConfiguration(String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로 및 사이트 이름을 사용하여 읽기 또는 쓰기 작업을 허용합니다.

public:
 static System::Configuration::Configuration ^ OpenWebConfiguration(System::String ^ path, System::String ^ site);
public static System.Configuration.Configuration OpenWebConfiguration (string path, string site);
static member OpenWebConfiguration : string * string -> System.Configuration.Configuration
Public Shared Function OpenWebConfiguration (path As String, site As String) As Configuration

매개 변수

path
String

구성 파일의 가상 경로입니다.

site
String

IIS(인터넷 정보 서비스) 구성에 표시되는 애플리케이션 웹 사이트의 이름입니다.

반환

Configuration

Configuration 개체입니다.

예외

올바른 구성 파일을 로드할 수 없는 경우

예제

다음 예제에서는 사용 하 여 구성 정보에 액세스 하는 방법의 OpenWebConfiguration 메서드.


// Show how to use OpenWebConfiguration(string, string).
// It gets he appSettings section of a Web application 
// runnig on the local server. 
static void OpenWebConfiguration2()
{
    // Get the configuration object for a Web application
    // running on the local server. 
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenWebConfiguration("/configTest", 
        "Default Web Site")
        as System.Configuration.Configuration;

    // Get the appSettings.
    KeyValueConfigurationCollection appSettings =
         config.AppSettings.Settings;

    // Loop through the collection and
    // display the appSettings key, value pairs.
    Console.WriteLine(
        "[appSettings for app at: /configTest");
    Console.WriteLine(" and site: Default Web Site]");

    foreach (string key in appSettings.AllKeys)
    {
        Console.WriteLine("Name: {0} Value: {1}",
        key, appSettings[key].Value);
    }

    Console.WriteLine();
}
' Show how to use OpenWebConfiguration(string, string).
' It gets he appSettings section of a Web application 
' runnig on the local server. 
Shared Sub OpenWebConfiguration2()
   ' Get the configuration object for a Web application
   ' running on the local server. 
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenWebConfiguration( _
     "/configTest", "Default Web Site")
   
   ' Get the appSettings.
     Dim appSettings As KeyValueConfigurationCollection = _
     config.AppSettings.Settings
   
   
   ' Loop through the collection and
   ' display the appSettings key, value pairs.
   Console.WriteLine("[appSettings for app at: /configTest")
   Console.WriteLine(" and site: Default Web Site]")
   
   Dim key As String
   For Each key In  appSettings.AllKeys
         Console.WriteLine("Name: {0} Value: {1}", _
         key, appSettings(key).Value)
   Next key
   
   Console.WriteLine()
End Sub

설명

가져올는 Configuration 개체는 리소스에 대 한 코드 설정을 상속 하는 모든 구성 파일에 대 한 권한이 읽기 있어야 합니다. 구성 파일을 업데이트 하려면 구성 파일 및 존재 하는 디렉터리에 대 한 쓰기 권한이 또한으로 코드에 있어야 합니다.

추가 정보

적용 대상

OpenWebConfiguration(String, String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름 및 위치를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

public:
 static System::Configuration::Configuration ^ OpenWebConfiguration(System::String ^ path, System::String ^ site, System::String ^ locationSubPath);
public static System.Configuration.Configuration OpenWebConfiguration (string path, string site, string locationSubPath);
static member OpenWebConfiguration : string * string * string -> System.Configuration.Configuration
Public Shared Function OpenWebConfiguration (path As String, site As String, locationSubPath As String) As Configuration

매개 변수

path
String

구성 파일의 가상 경로입니다.

site
String

IIS(인터넷 정보 서비스) 구성에 표시되는 애플리케이션 웹 사이트의 이름입니다.

locationSubPath
String

구성이 적용되는 특정 리소스입니다.

반환

Configuration

Configuration 개체입니다.

예외

올바른 구성 파일을 로드할 수 없는 경우

예제

다음 예제에서는 사용 하 여 구성 정보에 액세스 하는 방법의 OpenWebConfiguration 메서드.


// Show how to use OpenWebConfiguration(string, string, string).
// It gets he appSettings section of a Web application 
// runnig on the local server. 
static void OpenWebConfiguration3()
{
    // Get the configuration object for a Web application
    // running on the local server. 
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenWebConfiguration(
        "/configTest", "Default Web Site", null)
        as System.Configuration.Configuration;

    // Get the appSettings.
    KeyValueConfigurationCollection appSettings =
         config.AppSettings.Settings;

    // Loop through the collection and
    // display the appSettings key, value pairs.
    Console.WriteLine(
        "[appSettings for app at: /configTest");
    Console.WriteLine(" site: Default Web Site");
    Console.WriteLine(" and locationSubPath: null]");
    
    foreach (string key in appSettings.AllKeys)
    {
        Console.WriteLine("Name: {0} Value: {1}",
        key, appSettings[key].Value);
    }

    Console.WriteLine();
}
' Show how to use OpenWebConfiguration(string, string, string).
' It gets he appSettings section of a Web application 
' runnig on the local server. 
Shared Sub OpenWebConfiguration3()
   ' Get the configuration object for a Web application
   ' running on the local server. 
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenWebConfiguration( _
     "/configTest", "Default Web Site", Nothing)
   
   ' Get the appSettings.
     Dim appSettings As KeyValueConfigurationCollection = _
     config.AppSettings.Settings
   
   ' Loop through the collection and
   ' display the appSettings key, value pairs.
   Console.WriteLine("[appSettings for app at: /configTest")
   Console.WriteLine(" site: Default Web Site")
   Console.WriteLine(" and locationSubPath: null]")
   
   Dim key As String
   For Each key In  appSettings.AllKeys
         Console.WriteLine("Name: {0} Value: {1}", _
         key, appSettings(key).Value)
   Next key
   
   Console.WriteLine()
End Sub

설명

가져올는 Configuration 개체는 리소스에 대 한 코드 설정을 상속 하는 모든 구성 파일에 대 한 권한이 읽기 있어야 합니다. 구성 파일을 업데이트 하려면 구성 파일 및 존재 하는 디렉터리에 대 한 쓰기 권한이 또한으로 코드에 있어야 합니다.

추가 정보

적용 대상

OpenWebConfiguration(String, String, String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름, 위치 및 서버를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

public:
 static System::Configuration::Configuration ^ OpenWebConfiguration(System::String ^ path, System::String ^ site, System::String ^ locationSubPath, System::String ^ server);
public static System.Configuration.Configuration OpenWebConfiguration (string path, string site, string locationSubPath, string server);
static member OpenWebConfiguration : string * string * string * string -> System.Configuration.Configuration
Public Shared Function OpenWebConfiguration (path As String, site As String, locationSubPath As String, server As String) As Configuration

매개 변수

path
String

구성 파일의 가상 경로입니다.

site
String

IIS(인터넷 정보 서비스) 구성에 표시되는 애플리케이션 웹 사이트의 이름입니다.

locationSubPath
String

구성이 적용되는 특정 리소스입니다.

server
String

웹 애플리케이션이 상주하는 서버의 네트워크 이름입니다.

반환

Configuration

Configuration 개체입니다.

예외

서버 매개 변수가 잘못된 경우

올바른 구성 파일을 로드할 수 없는 경우

예제

다음 예제에서는 사용 하 여 구성 정보에 액세스 하는 방법의 OpenWebConfiguration 메서드.


// Show how to use OpenWebConfiguration(string, string, 
// string, string).
// It gets he appSettings section of a Web application 
// running on the specified server. 
// If the server is remote your application must have the
// required access rights to the configuration file. 
static void OpenWebConfiguration4()
{
    // Get the configuration object for a Web application
    // running on the specified server.
    // Null for the subPath signifies no subdir. 
    System.Configuration.Configuration config =
           WebConfigurationManager.OpenWebConfiguration(
            "/configTest", "Default Web Site", null, "myServer")
           as System.Configuration.Configuration;
    
    // Get the appSettings.
    KeyValueConfigurationCollection appSettings =
         config.AppSettings.Settings;

    // Loop through the collection and
    // display the appSettings key, value pairs.
    Console.WriteLine("[appSettings for Web app on server: myServer]");
    foreach (string key in appSettings.AllKeys)
    {
        Console.WriteLine("Name: {0} Value: {1}",
        key, appSettings[key].Value);
    }

    Console.WriteLine();
}
' Show how to use OpenWebConfiguration(string, string, 
' string, string).
' It gets he appSettings section of a Web application 
' running on the specified server. 
' If the server is remote your application must have the
' required access rights to the configuration file. 
Shared Sub OpenWebConfiguration4()
   ' Get the configuration object for a Web application
   ' running on the specified server.
   ' Null for the subPath signifies no subdir. 
   Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration("/configTest", "Default Web Site", Nothing, "myServer")
   
   ' Get the appSettings.
   Dim appSettings As KeyValueConfigurationCollection = config.AppSettings.Settings
   
   
   ' Loop through the collection and
   ' display the appSettings key, value pairs.
   Console.WriteLine("[appSettings for Web app on server: myServer]")
   Dim key As String
   For Each key In  appSettings.AllKeys
      Console.WriteLine("Name: {0} Value: {1}", key, appSettings(key).Value)
   Next key
   
   Console.WriteLine()
End Sub

설명

가져올는 Configuration 개체는 원격 리소스에 대 한 코드는 원격 컴퓨터에서 관리자 권한이 있어야 합니다.

추가 정보

적용 대상

OpenWebConfiguration(String, String, String, String, IntPtr)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름, 위치, 서버 및 보안 컨텍스트를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

public:
 static System::Configuration::Configuration ^ OpenWebConfiguration(System::String ^ path, System::String ^ site, System::String ^ locationSubPath, System::String ^ server, IntPtr userToken);
public static System.Configuration.Configuration OpenWebConfiguration (string path, string site, string locationSubPath, string server, IntPtr userToken);
static member OpenWebConfiguration : string * string * string * string * nativeint -> System.Configuration.Configuration
Public Shared Function OpenWebConfiguration (path As String, site As String, locationSubPath As String, server As String, userToken As IntPtr) As Configuration

매개 변수

path
String

구성 파일의 가상 경로입니다.

site
String

IIS(인터넷 정보 서비스) 구성에 표시되는 애플리케이션 웹 사이트의 이름입니다.

locationSubPath
String

구성이 적용되는 특정 리소스입니다.

server
String

웹 애플리케이션이 상주하는 서버의 네트워크 이름입니다.

userToken
IntPtr

nativeint

사용할 계정 토큰입니다.

반환

Configuration

Configuration 개체입니다.

예외

server 또는 userToken 매개 변수가 잘못된 경우

올바른 구성 파일을 로드할 수 없는 경우

예제

다음 예제에서는 사용 하는 방법의 OpenWebConfiguration 구성 정보에 액세스 하는 메서드.


// Show how to use OpenWebConfiguration(string, string, 
// string, string, IntPtr).
// It gets he appSettings section of a Web application 
// running on a remote server. 
// If the serve is remote your application shall have the
// requires access rights to the configuration file. 
static void OpenWebConfiguration6()
{

    IntPtr userToken = 
        System.Security.Principal.WindowsIdentity.GetCurrent().Token;
   
    string user = 
        System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    
    // Get the configuration object for a Web application
    // running on a remote server.
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenWebConfiguration(
        "/configTest", "Default Web Site", null, 
        "myServer", userToken) as System.Configuration.Configuration;

    // Get the appSettings.
    KeyValueConfigurationCollection appSettings =
         config.AppSettings.Settings;

    // Loop through the collection and
    // display the appSettings key, value pairs.
    Console.WriteLine(
        "[appSettings for Web app on server: myServer user: {0}]", user);
    foreach (string key in appSettings.AllKeys)
    {
        Console.WriteLine("Name: {0} Value: {1}",
        key, appSettings[key].Value);
    }

    Console.WriteLine();
}
' Show how to use OpenWebConfiguration(string, string, 
' string, string, IntPtr).
' It gets he appSettings section of a Web application 
' running on a remote server. 
' If the serve is remote your application shall have the
' requires access rights to the configuration file. 
Shared Sub OpenWebConfiguration6()
   
     Dim userToken As IntPtr = _
     System.Security.Principal.WindowsIdentity.GetCurrent().Token
   
     Dim user As String = _
     System.Security.Principal.WindowsIdentity.GetCurrent().Name
   
   ' Get the configuration object for a Web application
   ' running on a remote server.
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenWebConfiguration( _
     "/configTest", "Default Web Site", _
     Nothing, "myServer", userToken)
   
   ' Get the appSettings.
     Dim appSettings As KeyValueConfigurationCollection = _
     config.AppSettings.Settings
   
   ' Loop through the collection and
   ' display the appSettings key, value pairs.
     Console.WriteLine( _
     "[appSettings for Web app on server: myServer user: {0}]", user)
   Dim key As String
   For Each key In  appSettings.AllKeys
         Console.WriteLine("Name: {0} Value: {1}", _
         key, appSettings(key).Value)
   Next key
   
   Console.WriteLine()
End Sub

설명

이 메서드는 가장을 사용 하 여 구성 파일에 액세스 하려면 사용 됩니다.

참고

계정 토큰은 일반적으로 클래스의 WindowsIdentity 인스턴스에서 검색되거나 Windows API LogonUser호출과 같은 관리되지 않는 코드에 대한 호출을 통해 검색됩니다. 비관리 코드에 대 한 호출에 대 한 자세한 내용은 참조 하세요. 관리 되지 않는 DLL 함수 사용합니다.

가져올는 Configuration 개체는 원격 리소스에 대 한 코드는 원격 컴퓨터에서 관리자 권한이 있어야 합니다.

추가 정보

적용 대상

OpenWebConfiguration(String, String, String, String, String, String)

웹 응용 프로그램 구성 파일을 Configuration 개체로 열어 지정된 가상 경로, 사이트 이름, 위치, 서버 및 보안 컨텍스트를 사용하여 읽기 또는 쓰기 작업을 허용합니다.

public:
 static System::Configuration::Configuration ^ OpenWebConfiguration(System::String ^ path, System::String ^ site, System::String ^ locationSubPath, System::String ^ server, System::String ^ userName, System::String ^ password);
public static System.Configuration.Configuration OpenWebConfiguration (string path, string site, string locationSubPath, string server, string userName, string password);
static member OpenWebConfiguration : string * string * string * string * string * string -> System.Configuration.Configuration
Public Shared Function OpenWebConfiguration (path As String, site As String, locationSubPath As String, server As String, userName As String, password As String) As Configuration

매개 변수

path
String

구성 파일의 가상 경로입니다.

site
String

IIS(인터넷 정보 서비스) 구성에 표시되는 애플리케이션 웹 사이트의 이름입니다.

locationSubPath
String

구성이 적용되는 특정 리소스입니다.

server
String

웹 애플리케이션이 상주하는 서버의 네트워크 이름입니다.

userName
String

파일을 열 때 사용할 전체 사용자 이름(Domain\User)입니다.

password
String

사용자 이름에 대한 암호입니다.

반환

Configuration

Configuration 개체입니다.

예외

server 또는 userNamepassword 매개 변수가 잘못된 경우

올바른 구성 파일을 로드할 수 없는 경우

예제

다음 예제에서는 사용 하 여 구성 정보에 액세스 하는 방법의 OpenWebConfiguration 메서드.


// Show how to use OpenWebConfiguration(string, string, 
// string, string, string, string).
// It gets he appSettings section of a Web application 
// running on a remote server. 
// If the server is remote your application must have the
// required access rights to the configuration file. 
static void OpenWebConfiguration5()
{
    // Get the current user.
    string user =
        System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    
    // Assign the actual password.
    string password = "userPassword";

    // Get the configuration object for a Web application
    // running on a remote server.
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenWebConfiguration(
        "/configTest", "Default Web Site", null, "myServer",
        user, password) as System.Configuration.Configuration;

    // Get the appSettings.
    KeyValueConfigurationCollection appSettings =
         config.AppSettings.Settings;

    // Loop through the collection and
    // display the appSettings key, value pairs.
    Console.WriteLine(
        "[appSettings for Web app on server: myServer user: {0}]", user);
    foreach (string key in appSettings.AllKeys)
    {
        Console.WriteLine("Name: {0} Value: {1}",
        key, appSettings[key].Value);
    }

    Console.WriteLine();
}
' Show how to use OpenWebConfiguration(string, string, 
' string, string, string, string).
' It gets he appSettings section of a Web application 
' running on a remote server. 
' If the server is remote your application must have the
' required access rights to the configuration file. 
Shared Sub OpenWebConfiguration5()
   ' Get the current user.
     Dim user As String = _
     System.Security.Principal.WindowsIdentity.GetCurrent().Name
   
   ' Assign the actual password.
   Dim password As String = "userPassword"
   
   ' Get the configuration object for a Web application
   ' running on a remote server.
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenWebConfiguration( _
     "/configTest", "Default Web Site", _
     Nothing, "myServer", user, password)
   
   ' Get the appSettings.
     Dim appSettings As KeyValueConfigurationCollection = _
     config.AppSettings.Settings
   
   
   ' Loop through the collection and
   ' display the appSettings key, value pairs.
     Console.WriteLine( _
     "[appSettings for Web app on server: myServer user: {0}]", user)
   Dim key As String
   For Each key In  appSettings.AllKeys
         Console.WriteLine("Name: {0} Value: {1}", _
         key, appSettings(key).Value)
   Next key
   
   Console.WriteLine()
End Sub

설명

이 메서드는 가장을 사용 하 여 구성 파일에 액세스 하려면 사용 됩니다.

가져올는 Configuration 개체는 원격 리소스에 대 한 코드는 원격 컴퓨터에서 관리자 권한이 있어야 합니다.

실행 해야 할 수도 합니다 ASP.NET IIS Registration Tool (Aspnet_regiis.exe) 사용 하 여는 -config+ 원격 컴퓨터의 구성 파일에 대 한 액세스를 사용 하는 옵션입니다.

추가 정보

적용 대상