Programming Microsoft ASP.NET 4 - Dino Esposito [68]
preCondition
Specifies conditions under which the handler will run. (More information appears later in this section.)
requireAccess
Indicates the type of access that a handler requires to the resource, either read, write, script, execute, or none. The default is script.
resourceType
Indicates the type of resource to which the handler mapping applies: file, directory, or both. The default option, however, is Unspecified, meaning that the handler can handle requests for resources that map to physical entries in the file system as well as to plain commands.
responseBufferLimit
Specifies the maximum size, in bytes, of the response buffer. The default value is 4 MB.
scriptProcessor
Specifies the physical path of the ISAPI extension or CGI executable that processes the request. It is not requested for managed handlers.
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 global assembly cache.
verb
Indicates the list of the supported HTTP verbs—for example, GET, PUT, and POST. The wildcard character (*) is an acceptable value and denotes all verbs.
The reason why the configuration of an HTTP handler might span a larger number of attributes in IIS is that the Preconditions for Managed Handlers Table 4-4. Preconditions for an IIS 7.x HTTP Handler Precondition Description bitness32 The handler is 32-bit code and should be loaded only in 64-bit worker processes running in 32-bit emulation. bitness64 The handler is 64-bit and should be loaded only in native 64-bit worker processes. integratedMode The handler should respond only to requests in application pools configured in integrated mode. ISAPIMode The handler should respond only to requests in application pools configured in classic mode. runtimeVersionv1.1 The handler should respond only to requests in application pools configured for version 1.1 of the ASP.NET runtime. runtimeVersionv2.0 The handler should respond only to requests in application pools configured for version 2.0 of the ASP.NET runtime. Most of the time you use the integratedMode value only to set preconditions on a managed HTTP handler. Handlers Serving New Types of Resources More in general, you use HTTP handlers in two main situations: when you want to customize how known resources are processed and when you want to introduce new resources. In the latter case, you probably need to let IIS know about the new resource. Again, how you achieve this depends on the configuration of the application pool that hosts your ASP.NET applications. Suppose you want your application to respond to requests for .report requests. For example, you expect your application to be able to respond to a URL like /monthly.report?year=2010. Let’s say that monthly.report is a server file that contains a description of the report your handler will then create using any input parameters you provide. In integrated mode, you need to do nothing special for this request to go successfully. Moreover, you don’t even need to add a .report or any other analogous
The preCondition attribute sets prerequisites for the handler to run. Prerequisites touch on three distinct areas: bitness, ASP.NET runtime version, and type of requests to respond. Table 4-4 lists and explains the various options:
In ASP.NET applications, a common scenario when you want to use custom HTTP handlers is that you want to loosen yourself from the ties of ASPX files. Sometimes you want to place a request for a nonstandard ASP.NET resource (for example, a custom XML file) and expect the handler to process the content and return some markup.