Compartilhar via


<add> Element for <httpHandlers>

Adds a handler to an application. A handler is an IHttpHandler or IHttpHandlerFactory class that processes requests for specific URLs.

<configuration>
   <system.web>
      <httpHandlers>
         <add>

<add verb="verb list" 
     path="path/wildcard" 
     type="type,assemblyname"
     validate="true|false"/>

Required Attributes

Attribute Description
verb The verb list can be either a comma-separated list of HTTP verbs (for example, "GET, PUT, POST") or a start-script mapping (for example, the wildcard character * [an asterisk]).
path The path attribute can contain either a single URL path or a simple wildcard string (for example, *.aspx).
type Specifies a comma-separated class/assembly combination. ASP.NET searches for the assembly DLL first in the application's private \bin directory and then in the system assembly cache.

Optional Attribute

Attribute Description
validate If validate is set to false, ASP.NET will not attempt to load the class until the actual matching request comes, potentially delaying the error but improving start-up time.

Remarks

The <httpHandlers> settings are inherited by subdirectories.

The <add> directives are processed in top-down sequential order. If two or more <add> subelements specify the same verb/path combination, the final <add> overrides all others.

Microsoft Internet Information Services (IIS) has its own concept of mapping extensions to ISAPIs. For the settings for a given extension in this section to take effect, the extension must be mapped in IIS to ASP.NET ISAPI. For nonstandard extensions (something other than .aspx, .asmx, .asax, and so on), you must configure IIS.

Example

The following example maps all HTTP requests for files with file name extension .New to the class MyHandler.New and for HTTP GET and HTTP HEAD requests for files with file name extension .MyNewFileExtension to the class MyHandler.MNFEHandler. Both classes are in the assembly MyHandler that is in the file MyHandler.dll.

<configuration>
   <system.web>
      <httpHandlers>
         <add verb="*" 
              path="*.New" 
              type="MyHandler.New,MyHandler"/>
         <add verb="GET,HEAD" 
              path="*.MyNewFileExtension" 
              type="MyHandler.MNFEHandler,MyHandler.dll"/>
     </httpHandlers>
   <system.web>
</configuration>

Requirements

Contained Within: <system.web>

Web Platform: IIS 5.0, IIS 5.1, IIS 6.0

Configuration File: Machine.config, Web.config

Configuration Section Handler: System.Web.Configuration.HttpHandlersSectionHandler

See Also

<httpHandlers> Element | ASP.NET Configuration | ASP.NET Settings Schema