0

In IIS7 we can tell a module to run for managed content (thus speeding up static content serving) by:

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

But. This works fine and dandy as long as there's also a file name (with extension) in the requested URL. If it's omitted it IIS7 will think you want static content and managed modules won't run.

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

If I manually set IIS7 default document, so the first one will be default.aspx, I can see no difference. To me this looks, walks and sounds like a bug. And it is a bug! Why? Because when I request for the first one, it is a managed request, isn't it. Of course it is. But IIS7 treats it as a static request. So? It's a bug. This request should be treated 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 bit with thinking: If I'd reorder system.webServer/handlers, I'm sure could solve this. Before the last StaticFile handler that points to StaticFileModule, DefaultDocumentModule and DirectoryBrowsingModule I should be running integrated asp.net handler on Directory requests. Or write my own handler, that would append default document to any directory request. I'm pretty sure one of these should solve it. But how would I have to configure/develop it?

Robert Koritnik
  • 912
  • 5
  • 19
  • 35

2 Answers2

0

This is not a bug - it is how the managed handler pre-condition works. It makes it so that the module will only be processed by pages that have a managed handler defined for them.

You can take the pre-condition off, and then it will parse everything - but then you lose the performance gains of not parsing your static content.

Your best bet is probably to have all of your static content in a separate directory, and use web.config to remove the module.

MattB
  • 11,194
  • 1
  • 30
  • 36
  • Is this StaticFile handler (or maybe module) behaviour? What about UrlRewriting that runs before it? – Robert Koritnik Aug 12 '09 at 19:26
  • I don't think it has anything to do with the handler itself - it is because you are putting the precondition on adding your module. Not sure what would happen if you did a URLRewrite on it. – MattB Aug 12 '09 at 21:36
  • It is a bug. If I request a path without filename at the end, DefaultDocument presence should determine whether it's a managed or static request. It shouldn't be just static... – Robert Koritnik Sep 02 '09 at 08:16
0

This is the actual solution, that solves this managed request bug
Answer on Stackoverflow.com

Robert Koritnik
  • 912
  • 5
  • 19
  • 35