13
votes

After reading some documentation about the integrated pipeline I'm confused about how IIS determines when to run managed modules, what a managed request actually is, and how that is determined, e.g.:

http://www.iis.net/learn/application-frameworks/building-and-running-aspnet-applications/aspnet-integration-with-iis http://blogs.msdn.com/b/tmarq/archive/2007/08/30/iis-7-0-asp-net-pipelines-modules-handlers-and-preconditions.aspx

"Managed" requests are mentioned several times. There's one instance where it is explained that a managed request is a request that has a mapping to a managed handler. There's also a quote saying that a handler is a "special" module (second link).

Modules are described as something that runs for every request and that a handler has a mapping that specifies when it should run (e.g. HTTP GET for *.aspx) (second and first links). Furthermore, for the modules the execute_request_handler [which I'm assuming as the point where the handler actually runs] comes after several stages of the pipeline (after begin_request, authenticate, authorize, etc...), it implies that there's a step that happens before all that, that establishes that the request is for a managed handler, so as to disable the execution of modules that have the preCondition="managedHanlder" when the request is not for a managed handler.

I feel there's something I'm missing here, can someone shed some light about how does preCondition="managedHandler" exactly works?

1

1 Answers

8
votes

From this blog post (http://blogs.iis.net/thomad/archive/2006/11/04/precondition-what.aspx) :

The ManagedHandler precondition

IIS 7.0 introduces a new managed extensibility model. Handlers and Modules can now be written in managed code and directly integrated into the IIS request pipeline. But switching between managed and native code is an expensive operation. The managedHandler precondition was introduced to allow optimizing the performance of requests where no managed code needs to be involved, for example when static files (.html, .jpg etc.) are served. No managed code is called if the request is served by a native handler and every managed module is configured with the managedHandler precondition. A practical scenario is Forms authentication. The managed Forms authentication module has a managedHandler precondition and is therefore only called when ASP.NET content (e.g. *.aspx) pages are requested. If a .html page is requested the forms authentication is not called. If you want to protect all your content with forms authentication you can simply remove the managedHandler precondition from the Forms authentication module entry.

In short, if a request can be served by a native IIS module (say, an image for instance), it will not have to go through all the managed pipeline (for instance, all the "global.asax" events and even more), resulting in a huge performance gain.

EDIT: The actual answer to your question is : Handlers mappings. This is what associates a file extension to a specific handler. You will find below how to edit these mappings in II7. You can also find more information about handler mapping here.

open this section in IIS

Then you will see all the registered mappings