This project is read-only.

Serving static content directly - bypassing the .NET pipeline

Topics: Core
Feb 4, 2013 at 6:11 PM
Root Orchard Web.Config has this line:
<modules runAllManagedModulesForAllRequests="true">
On a subdir (e.g Themes/VARV/Content), there are web.configs used for serving static content. They work, BUT, are going through the pipeline.

Example – I want this to be a fast 404, it isn’t. It’s slow because it’s actually throwing a 500!

If I set that flag above to “false”, static content, images, javascript, etc. don’t go through the pipeline and are served MUCH faster.

I’m struggling with this.

Inside Themes/VARV/Content Web.Config I tried overriding the setting, but it doesn’t work:
<modules runAllManagedModulesForAllRequests="false">
  <remove name="UrlRoutingModule-4.0" />
  <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
The requests still go through the pipeline. I don’t want them to!

So my question is, on the root Web.Config, if I set that runAllManagedModulesForAllRequests=false, will it cause any problems? I’ve set it to false and the site SEEMS to be working fine, but I’m not sure.

I found this recent article that does a good job explaining:

But I’m still not sure if I need to go through every Orchard Module config and set the ‘preCondition=true’, if that’s the right approach?
May 21, 2013 at 10:26 PM
Did you ever get a response on this or figure out if it caused side-effects? I am considering setting it to false as well...
May 21, 2013 at 11:35 PM
runAllManagedModulesForAllRequests="false" is the new default in Orchard
May 22, 2013 at 5:51 PM
First off - thank you for the response. We are using Orchard 1.6 and if we switch this setting to false, can you tell us if the out of the box Orchard installation will have any problems? Thanks again...
Aug 26, 2013 at 11:17 AM
Setting this value as true, same as Visual Stuidio does, is much safer than 'false'. On my sites ... after upgrade to Orchard 1.7, I've got 401 http errors on all css and js files. It was hard to find that runAllManagedModulesForAllRequests is responsible for that. Of coz this should work with runAllManagedModulesForAllRequests set as false also and I will try to figure out why setting it to false makes all css files blank.

In my opinion all default settings for Orchard should be set as safe as possible. When some customer doesn't see ORchard working is much wore thing that it works a little bit slowly. There should be a page in documentation for tuning Orchard and there should be explained that runAllManagedModulesForAllRequests can be set to false in some circumstances.
Aug 27, 2013 at 8:41 PM
Yes. We left it as false and that's the ideal setting. The fix for static files failing was simply to comment out the IIS 6 directive, line 9 below. Once that was done, the failed static request issue went away.
<?xml version="1.0" encoding="UTF-8"?>
    <add key="webpages:Enabled" value="false" />
      <!-- iis6 - for any request in this location, return via managed static file handler -->
      <!--<add path="*" verb="*" type="System.Web.StaticFileHandler" />-->
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="font/x-woff" />
    <handlers accessPolicy="Script,Read">
      iis7 - for any request to a file exists on disk, return it via native http module.
      accessPolicy 'Script' is to allow for a managed 404 page.
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />