Share via


처리기 <처리기>

개요

요소는 <handlers> 특정 파일 이름 확장명 또는 URL에 대해 등록된 처리기를 정의합니다.

처리기는 특정 콘텐츠에 대한 요청을 처리하도록 구성된 IIS(인터넷 정보 서비스) 구성 요소로, 일반적으로 요청 리소스에 대한 응답을 생성합니다. 예를 들어 ASP.NET 웹 페이지는 처리기의 한 유형입니다. 처리기를 사용하여 정적 파일이 아닌 사용자에게 정보를 반환해야 하는 모든 리소스에 대한 요청을 처리할 수 있습니다. IIS는 정적 파일, CGI(Common Gateway Interface) 애플리케이션, FastCGI 애플리케이션 및 ISAPI(인터넷 서버 API) 확장을 지원하는 여러 처리기 유형을 제공합니다. ASP.NET HTTP 처리기 인터페이스를 통해 추가 처리기 형식에 대한 지원도 제공합니다.

개발자는 애플리케이션에서 파일 이름 확장명을 사용하여 식별할 수 있는 특수 처리를 수행하는 사용자 지정 처리기를 만들 수 있습니다. 예를 들어 개발자가 RSS 형식 XML을 만든 처리기를 만든 경우 애플리케이션의 .rss 파일 이름 확장명을 사용자 지정 처리기에 바인딩할 수 있습니다. 개발자는 특정 파일에 매핑되는 처리기를 만들 수도 있으며 이러한 처리기를 네이티브 모듈 또는 ASP.NET IHttpHandler 인터페이스의 구현으로 구현할 수 있습니다.

호환성

버전 참고
IIS 10.0 <handlers> 요소가 IIS 10.0에서 수정되지 않았습니다.
IIS 8.5 <handlers> 요소가 IIS 8.5에서 수정되지 않았습니다.
IIS 8.0 <handlers> 요소가 IIS 8.0에서 수정되지 않았습니다.
IIS 7.5 <handlers> 요소가 IIS 7.5에서 수정되지 않았습니다.
IIS 7.0 요소는 <handlers> IIS 7.0에서 도입되었습니다.
IIS 6.0 해당 없음

설치 프로그램

요소는 <handlers> IIS 7의 기본 설치에 포함됩니다.

방법

통합 모드에서 실행되는 IIS 7 애플리케이션에서 ASP.NET 처리기에 대한 처리기 매핑을 만드는 방법

  1. IIS(인터넷 정보 서비스) 관리자를 엽니다.

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1 사용하는 경우:

      • Windows 키를 누른 채로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리 도구를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 연결 창에서 네이티브 모듈을 추가할 서버 연결을 클릭합니다.

  3. 창에서 처리기 매핑을 두 번 클릭합니다.
    처리기 매핑 기능이 선택된 홈 창의 스크린샷

  4. 작업 창에서 관리되는 처리기 추가...를 클릭합니다.

  5. 관리되는 처리기 추가 대화 상자에서 다음을 지정합니다.

    • 요청 경로입니다. 매핑할 파일 이름 또는 파일 이름 확장명입니다.

    • Type. 관리되는 처리기의 형식(클래스) 이름입니다. 처리기가 애플리케이션의 app_code 또는 bin 폴더에 정의된 경우 해당 형식 이름이 드롭다운 목록에 표시됩니다.

    • 이름. 설명이 포함된 이름입니다.

      스크린샷은 요청 경로, 유형 및 이름에 대한 필드가 있는 관리되는 처리기 추가 대화 상자를 보여줍니다.

  6. 확인을 클릭하여 관리되는 처리기 추가 대화 상자를 닫습니다.

FastCGI 처리기 매핑을 만드는 방법

  1. IIS(인터넷 정보 서비스) 관리자를 엽니다.

    • Windows Server 2012 또는 Windows Server 2012 R2를 사용하는 경우:

      • 작업 표시줄에서 서버 관리자 클릭하고 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows 8 또는 Windows 8.1 사용하는 경우:

      • Windows 키를 누른 채로 문자 X를 누른 다음 제어판 클릭합니다.
      • 관리 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
    • Windows Server 2008 또는 Windows Server 2008 R2를 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭하고 관리 도구를 가리킨 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
    • Windows Vista 또는 Windows 7을 사용하는 경우:

      • 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
      • 관리 도구를 두 번 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 연결 창에서 FastCGI 처리기 매핑을 구성할 서버 이름을 클릭합니다.

  3. 창에서 처리기 매핑을 두 번 클릭합니다.
    처리기 매핑 기능이 선택된 서버 홈 창을 보여 주는 스크린샷

  4. 작업 창에서 모듈 매핑 추가...를 클릭합니다.

    참고

    다음 단계가 작동하려면 지정한 파일 경로 또는 파일 이름 확장명을 실행할 이진 파일이 이미 설치되어 있어야 합니다. 이 예제에서는 Microsoft 웹 사이트에서 사용할 수 있는 PHP 구현을 사용합니다.

  5. 요청 경로 상자에 파일 이름 확장명(예: .php)을 입력하고, 모듈 드롭다운 목록에서 FastCGIModule을 클릭하고, 실행 파일 상자에 스크립팅 엔진의 경로(이 예제에서는 PHP-CGI.exe)를 입력한 다음 확인을 클릭합니다.
    모듈 드롭다운 목록에서 빠른 CG I 모듈이 선택된 모듈 매핑 추가 대화 상자의 스크린샷

  6. 모듈 매핑 추가 대화 상자에서 예를 클릭합니다.
    스크린샷은 실행 파일에 대한 Fast C G I 애플리케이션을 만들 것인지 묻는 모듈 매핑 추가 대화 상자를 보여줍니다.

구성

<handlers> 요소는 요소의 <add> 컬렉션을 포함하며, 각 요소는 애플리케이션에 대한 처리기 매핑을 정의합니다. <add> 요소에는 처리기의 이름, 처리기가 매핑되는 파일 이름 확장명 또는 URL 경로 마스크, 처리기 구현을 지정하는 모듈 이름 또는 ASP.NET HTTP 처리기 형식이 포함됩니다.

Web.config 파일의 애플리케이션 수준에서 요소를 구성 <handlers> 합니다.

특성

attribute Description
accessPolicy 선택적 flags 특성입니다.

전체 처리기 컬렉션에 허용되는 액세스 형식을 지정합니다.

accessPolicy 특성은 다음과 같은 가능한 값 중 하나일 수 있습니다. 기본값은 Read입니다.
Description
Execute 디렉터리 및 파일에서 실행 권한이 필요한 처리기 컬렉션의 처리기를 사용하도록 설정합니다.
None 디렉터리 또는 파일에 액세스해야 하는 처리기 컬렉션의 모든 처리기를 사용하지 않도록 설정합니다.
NoRemoteExecute 처리기가 원격 요청을 받을 때 처리기 컬렉션의 처리기가 실행 파일을 실행하지 못하도록 방지합니다.
NoRemoteRead 처리기가 원격 요청을 받을 때 처리기 컬렉션의 처리기가 파일을 읽지 못하도록 합니다.
NoRemoteScript 처리기가 원격 요청을 받을 때 처리기 컬렉션의 처리기가 스크립트를 실행하지 못하도록 방지합니다.
NoRemoteWrite 처리기가 원격 요청을 받을 때 처리기 컬렉션의 처리기가 파일을 만들거나 변경하지 못하도록 합니다.
Read 디렉터리 및 파일에 대한 읽기 액세스 권한이 필요한 처리기 컬렉션에서 처리기를 사용하도록 설정합니다.
Script 디렉터리 또는 파일에 대한 스크립트 권한이 필요한 처리기 컬렉션에서 처리기를 사용하도록 설정합니다.
Source 소스 코드에 대한 읽기 액세스( 읽기 플래그와 함께) 또는 소스 코드에 대한 쓰기 액세스( 쓰기 플래그와 함께)가 필요한 처리기 컬렉션에서 처리기를 사용하도록 설정합니다.
Write 디렉터리 및 파일에 대한 쓰기 액세스 권한이 필요한 처리기 컬렉션에서 처리기를 사용하도록 설정합니다.

자식 요소

요소 Description
add 선택적 요소입니다.

처리기 컬렉션에 처리기를 추가합니다.
clear 선택적 요소입니다.

처리기 컬렉션에서 처리기에 대한 모든 참조를 제거합니다.
remove 선택적 요소입니다.

처리기 컬렉션에서 처리기에 대한 참조를 제거합니다.

구성 샘플

다음 예제에는 처리기 매핑을 정의하는 두 <add> 가지 요소가 포함되어 있습니다. 첫 번째 <add> 요소는 IIS 7 통합 모드에서 실행되는 웹 애플리케이션에 대한 SampleHandler 처리기를 정의합니다. 웹 애플리케이션의 app_code 디렉터리에 처리기 어셈블리를 추가하는 경우 형식 특성 값에 어셈블리 이름을 포함할 필요가 없습니다. 두 번째 <add> 요소는 FastCGI 모듈을 사용하는 PHP 요청에 대한 매핑을 정의합니다.

<handlers>
   <add name="SampleHandler" verb="*" 
      path="SampleHandler.new" 
      type="SampleHandler, SampleHandlerAssembly" 
      resourceType="Unspecified" />
   <add name="PHP-FastCGI" verb="*" 
      path="*.php" 
      modules="FastCgiModule"
      scriptProcessor="c:\php\php-cgi.exe" 
      resourceType="Either" />
</handlers>

샘플 코드

다음 예제에서는 PHP 모듈에 대한 FastCGI 매핑을 추가한 다음, PHP 요청을 처리할 Contoso 웹 사이트에 처리기를 추가합니다.

AppCmd.exe

appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='c:\php\php-cgi.exe']" /commit:apphost

appcmd.exe set config "Contoso" -section:system.webServer/handlers /+"[name='PHP-FastCGI',path='*.php',verb='GET,HEAD,POST',modules='FastCgiModule',scriptProcessor='c:\php\php-cgi.exe',resourceType='Either']"

참고

이 두 번째 예제에서는 특정 URL에 대해 SampleHandler.new라는 새 ASP.NET 처리기 매핑을 웹 애플리케이션에 추가하는 방법을 보여 줍니다.

appcmd.exe set config /section:system.webServer/handlers /+[name=SampleHandler',path='SampleHandler.new',verb='*',type='SampleHandler']

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration appHostConfig = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection fastCgiSection = appHostConfig.GetSection("system.webServer/fastCgi");
         ConfigurationElementCollection fastCgiCollection = fastCgiSection.GetCollection();
         ConfigurationElement applicationElement = fastCgiCollection.CreateElement("application");
         applicationElement["fullPath"] = @"c:\php\php-cgi.exe";
         fastCgiCollection.Add(applicationElement);

         Configuration webConfig = serverManager.GetWebConfiguration("Contoso");
         ConfigurationSection handlersSection = webConfig.GetSection("system.webServer/handlers");
         ConfigurationElementCollection handlersCollection = handlersSection.GetCollection();
         ConfigurationElement addElement = handlersCollection.CreateElement("add");
         addElement["name"] = @"PHP-FastCGI";
         addElement["path"] = @"*.php";
         addElement["verb"] = @"GET,HEAD,POST";
         addElement["modules"] = @"FastCgiModule";
         addElement["scriptProcessor"] = @"c:\php\php-cgi.exe";
         addElement["resourceType"] = @"Either";
         handlersCollection.AddAt(0, addElement);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim appHostConfig As Configuration = serverManager.GetApplicationHostConfiguration
      Dim fastCgiSection As ConfigurationSection = appHostConfig.GetSection("system.webServer/fastCgi")
      Dim fastCgiCollection As ConfigurationElementCollection = fastCgiSection.GetCollection
      Dim applicationElement As ConfigurationElement = fastCgiCollection.CreateElement("application")
      applicationElement("fullPath") = "c:\php\php-cgi.exe"
      fastCgiCollection.Add(applicationElement)

      Dim webConfig As Configuration = serverManager.GetWebConfiguration("Contoso")
      Dim handlersSection As ConfigurationSection = webConfig.GetSection("system.webServer/handlers")
      Dim handlersCollection As ConfigurationElementCollection = handlersSection.GetCollection
      Dim addElement As ConfigurationElement = handlersCollection.CreateElement("add")
      addElement("name") = "PHP-FastCGI"
      addElement("path") = "*.php"
      addElement("verb") = "GET,HEAD,POST"
      addElement("modules") = "FastCgiModule"
      addElement("scriptProcessor") = "c:\php\php-cgi.exe"
      addElement("resourceType") = "Either"
      handlersCollection.AddAt(0, addElement)

      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');

adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var fastCgiSection = adminManager.GetAdminSection("system.webServer/fastCgi", "MACHINE/WEBROOT/APPHOST");
var fastCgiCollection = fastCgiSection.Collection;
var applicationElement = fastCgiCollection.CreateNewElement("application");
applicationElement.Properties.Item("fullPath").Value = "c:\\php\\php-cgi.exe";
fastCgiCollection.AddElement(applicationElement);
adminManager.CommitChanges();

adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Contoso";
var handlersSection = adminManager.GetAdminSection("system.webServer/handlers", "MACHINE/WEBROOT/APPHOST/Contoso");
var handlersCollection = handlersSection.Collection;
var addElement = handlersCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "PHP-FastCGI";
addElement.Properties.Item("path").Value = "*.php";
addElement.Properties.Item("verb").Value = "GET,HEAD,POST";
addElement.Properties.Item("modules").Value = "FastCgiModule";
addElement.Properties.Item("scriptProcessor").Value = "c:\\php\\php-cgi.exe";
addElement.Properties.Item("resourceType").Value = "Either";
handlersCollection.AddElement(addElement, 0);
adminManager.CommitChanges();

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")

adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set fastCgiSection = adminManager.GetAdminSection("system.webServer/fastCgi", "MACHINE/WEBROOT/APPHOST")
Set fastCgiCollection = fastCgiSection.Collection
Set applicationElement = fastCgiCollection.CreateNewElement("application")
applicationElement.Properties.Item("fullPath").Value = "c:\php\php-cgi.exe"
fastCgiCollection.AddElement applicationElement
adminManager.CommitChanges()

adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Contoso"
Set handlersSection = adminManager.GetAdminSection("system.webServer/handlers", "MACHINE/WEBROOT/APPHOST/Contoso")
Set handlersCollection = handlersSection.Collection
Set addElement = handlersCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "PHP-FastCGI"
addElement.Properties.Item("path").Value = "*.php"
addElement.Properties.Item("verb").Value = "GET,HEAD,POST"
addElement.Properties.Item("modules").Value = "FastCgiModule"
addElement.Properties.Item("scriptProcessor").Value = "c:\php\php-cgi.exe"
addElement.Properties.Item("resourceType").Value = "Either"
handlersCollection.AddElement addElement, 0
adminManager.CommitChanges()