Error: IIS7 Managed Requests

(I don't know if I should also post this question to ServerFault, as it relates to IIS configuration?)

In IIS7, we can say that the module runs for managed content (thereby speeding up static content):

<modules> ... <add name="WhateverName" type="WhateverType" preCondition="managedHandler" ... </modules> 

But. This works fine and dandy, if the requested URL also has a file name (with extension). If he omitted it, IIS7 will think that static content and managed modules will not work.

 http://localhost/ <-- this one will skip managed handlers http://localhost/default.aspx <-- this one will run them 

If I manually set the default IIS7 document, so the first one is default.aspx , I don’t see the difference , there is no difference. For me it looks, walks and sounds like a mistake. And this is a mistake! Why? Because when I request the first, this is a managed request, isn't it. Of course it is. But IIS7 treats it as a static request. So? This is a mistake . This request should be considered as managed.

How can I convince IIS7 to run managed handlers for URL requests without file names inside?

Help with thinking

Let me help you a little: if I reorder system.webServer/handlers , I'm sure I can solve it. Before the last StaticFile handler, which points to StaticFileModule , DefaultDocumentModule and DirectoryBrowsingModule , I have to run the asp.net integrated handler in the Directory queries. Or write my own handler that will add a default document to any directory request. I am sure that one of them should solve this problem. But how do I configure / develop it?

+5
iis-7 configuration
source share
3 answers

The problem is the request processing order. IIS7 processes requests in the order specified by the IIS Handlers configuration item. By default, the IIS configuration handler element contains

 <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" /> 

at the end of handlers. Therefore, a whole request that does not match the previously specified handler will be processed by this handler (including also the folder request).

You can remove all default handlers by using the element to clear handlers in the configuration and specify your own request processing order.

I recommend copying the default IIS handler configuration (C: \ Windows \ System32 \ inetsrv \ config \ applicationHost.config) to your web configuration without the StaticFile handler at the end.

Then you must add a special static content handler for each static content type (jpg, gif, js, css).

 <add name="StaticFile-swf" path="*.swf" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFile-png" path="*.png" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFile-gif" path="*.gif" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFile-jpg" path="*.jpg" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFile-css" path="*.css" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> <add name="StaticFile-js" path="*.js" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" /> 

and a managed handler (PageHandlerFactory) for folder requests after that.

 <add name="PageHandlerFactory-Folders" path="*" verb="*" type="System.Web.UI.PageHandlerFactory" modules="ManagedPipelineHandler" resourceType="Unspecified" requireAccess="Read" allowPathInfo="false" preCondition="integratedMode" /> 

At the end, you should also add a StaticFile handler.

Here is an example.

+6
source share

Removing preCondition="managedHandler" or adding <modules runAllManagedModulesForAllRequests="true"> should do this. The section of this page has more information.

+1
source share

You can use wild card script mapping , but it is inefficient to use a managed handler to handle all requests. A static handler is much more efficient when it fits.

0
source share

All Articles