Вы находитесь на странице: 1из 3

ISAPI, or Internet Server API is a set of libraries exposed by the IIS in order to allow developers to create custom plugin

components for IIS. The ISAPI for IIS has two major components.

1. ISAPI Extensions - are similar to HttpHandlers in .NET 2. ISAPI Filters - are similar to HttpModules in .NET

ASP.NET request processing is based on a pipeline model in which ASP.NET passes http requests to all the modules in the pipeline. Each module receives the http request and has full control over it. The module can play with the request in any way it sees fit. Once the request passes through all of the HTTP modules, it is eventually served by an HTTP handler. The HTTP handler performs some processing on it, and the result again passes through the HTTP modules in the pipeline. The following figure describes this flow.

Notice that during the processing of an http request, only one HTTP handler will be called, whereas more than one HTTP modules can be called.

Http Handlers HTTP handlers are the .NET components that implement the System.Web.IHttpHandler interface. Any class that implements the IHttpHandler interface can act as a target for the incoming HTTP requests. HTTP handlers are somewhat similar to ISAPI extensions. One difference between HTTP handlers and ISAPI extensions is that HTTP handlers can be called directly by using their file name in the URL, similar to ISAPI extensions.

HTTP handlers are the end point objects in ASP.NET pipeline and an HTTP Handler essentially processes the request and produces the response. For example an ASP.NET Page is an HTTP Handler.

HTTP handlers implement the following methods. Method Name Description This method is actually the heart of all http handlers. This method is called to ProcessRequest process http requests. IsReusable This property is called to determine whether this instance of http handler can be reused for fulfilling another requests of the same type. HTTP handlers can return either true or false in order to specify whether they can be reused.

HTTP Modules HTTP modules are .NET components that implement the System.Web.IHttpModule interface. These components plug themselves into the ASP.NET request processing pipeline by registering themselves for certain events. Whenever those events occur, ASP.NET invokes the interested HTTP modules so that the modules can play with the request.
HTTP Modules are objects which also participate the pipeline but they work before and after the HTTP Handler does its job, and produce additional services within the pipeline (for example associating session within a request before HTTP handler executes, and saving the session state after HTTP handler has done its job, is basically done by an HTTP module, SessionStateModule)

An HTTP module is supposed to implement the following methods of the IHttpModule interface: Method Name Init Dispose Description This method allows an HTTP module to register its event handlers to the events in the HttpApplication object. This method gives HTTP module an opportunity to perform any clean up before the object gets garbage collected.

An HTTP module can register for the following events exposed by the System.Web.HttpApplication object. Event Name AcquireRequestState AuthenticateRequest AuthorizeRequest Description This event is raised when ASP.NET runtime is ready to acquire the Session state of the current HTTP request. This event is raised when ASP.NET runtime is ready to authenticate the identity of the user. This event is raised when ASP.NET runtime is ready to authorize

the user for the resources user is trying to access. BeginRequest Disposed EndRequest Error This event is raised when ASP.NET runtime receives a new HTTP request. This event is raised when ASP.NET completes the processing of HTTP request. This event is raised just before sending the response content to the client. This event is raised when an unhandled exception occurs during the processing of HTTP request.

PostRequestHandlerExecute This event is raised just after HTTP handler finishes execution. This event is raised just before ASP.NET begins executing a PreRequestHandlerExecute handler for the HTTP request. After this event, ASP.NET will forward the request to the appropriate HTTP handler. This event is raised just before ASP.NET sends the response contents to the client. This event allows us to change the contents before it gets delivered to the client. We can use this event to add the contents, which are common in all pages, to the page output. For example, a common menu, header or footer. This event is raised just before ASP.NET sends the HTTP response headers to the client. This event allows us to change the headers before they get delivered to the client. We can use this event to add cookies and custom data into headers. This event is raised after ASP.NET finishes executing all request handlers. This event is raised to determine whether the request can be fulfilled by returning the contents from the Output Cache. This depends on how the Output Caching has been setup for your web application. This event is raised when ASP.NET has completed processing the current HTTP request and the output contents are ready to be added to the Output Cache. This depends on how the Output Caching has been setup for your Web application.

PreSendRequestContent

PreSendRequestHeaders

ReleaseRequestState

ResolveRequestCache

UpdateRequestCache

Вам также может понравиться