ASP.NET 애플리케이션에서 권한 부여 권한 제어

이 업데이트에서는 Web.config 파일에 태그를 적용 <location> 하여 특정 파일 및 폴더에 대한 액세스를 구성하는 방법을 소개합니다.

원래 제품 버전: ASP.NET
원래 KB 번호: 316871

요약

이 단계별 가이드를 사용하여 Web.config 파일에 태그를 적용 <location> 하여 특정 파일 및 폴더에 대한 액세스를 구성합니다.

ASP.NET 애플리케이션에서 양식 기반 인증을 사용하는 경우 인증된 사용자만 애플리케이션의 페이지에 대한 액세스 권한을 부여합니다. 인증되지 않은 사용자는 자격 증명을 제출할 수 있는 Web.config 파일의 특성으로 loginUrl 지정된 페이지로 자동으로 리디렉션됩니다. 경우에 따라 사용자가 인증을 요구하지 않고 애플리케이션의 특정 페이지에 액세스할 수 있도록 허용할 수 있습니다.

특정 파일 및 폴더에 대한 액세스 구성

  1. 양식 기반 인증을 설정합니다. 자세한 내용은 C# .NET을 사용하여 ASP.NET 애플리케이션에서 Forms-Based 인증을 구현하는 방법을 참조하세요.

  2. 애플리케이션의 모든 페이지를 자동으로 Logon.aspx 리디렉션하도록 요청합니다.

  3. Web.config 파일에 다음 코드를 입력하거나 붙여넣습니다.

    이 코드는 모든 사용자에게 Default1.aspx 페이지 및 Subdir1 폴더에 대한 액세스 권한을 부여합니다.

    <configuration>
        <system.web>
            <authentication mode="Forms" >
                <forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
                </forms>
            </authentication>
            <!-- This section denies access to all files in this application except for those that you have not explicitly specified by using another setting. -->
            <authorization>
                <deny users="?" />
            </authorization>
        </system.web>
        <!-- This section gives the unauthenticated user access to the Default1.aspx page only. It is located in the same folder as this configuration file. -->
        <location path="default1.aspx">
            <system.web>
                <authorization>
                    <allow users ="*" />
                </authorization>
            </system.web>
        </location>
        <!-- This section gives the unauthenticated user access to all of the files that are stored in the Subdir1 folder. -->
        <location path="subdir1">
            <system.web>
                <authorization>
                    <allow users ="*" />
                </authorization>
            </system.web>
        </location>
    </configuration>
    

    사용자는 Default1.aspx 파일 또는 애플리케이션의 폴더에 subdir1 저장된 다른 파일을 열 수 있습니다. 인증을 위해 Logon.aspx 파일로 자동으로 리디렉션되지 않습니다.

  4. 3단계를 반복하여 인증되지 않은 사용자가 액세스를 허용하려는 다른 페이지 또는 폴더를 식별합니다.

참조