Can you add virtual directory applications into the Orchard virtual directory?

Topics: General, Installing Orchard, Troubleshooting
Nov 18, 2011 at 6:37 PM
Edited Nov 21, 2011 at 9:24 PM

Is Orchard able to support multiple custom apps inside its directory? When I try to do this I get a 404.4 Error that says : 

The resource you are looking for does not have a handler associated with it.

I basically need Orchard as the main site and accessible through a url like mydomain.com/orchardinstall, and then i have several custom apps that are virtual directories configured as applications that need to be referenced through mydomain.com/orchardinstall/customapp1.

Does Orchard support this and if so, what am I doing wrong? Thanks.

Coordinator
Nov 18, 2011 at 7:53 PM

The web.config in Orchard is locked down. What you need to do is change the config so that this lock down is not propagated to the vdir. This can be done either by setting inheritInChildApplications to false (see http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx) or you can restore in a web.config in your vdir the settings that were locked down by Orchard.

Nov 18, 2011 at 8:19 PM
Edited Nov 21, 2011 at 9:30 PM
bertrandleroy wrote:

The web.config in Orchard is locked down. What you need to do is change the config so that this lock down is not propagated to the vdir. This can be done either by setting inheritInChildApplications to false (see http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx) or you can restore in a web.config in your vdir the settings that were locked down by Orchard.

Excellent this worked, thanks! Just specifying for anyone else who may have this problem the location tag needs to open underneath the closing </configSections> tag in <configuration> and must close right above the opening <runtime> tag near the bottom, otherwise you get various other errors.

 

EDIT: This worked for only allowing the vdir application to work, but broke the orchard installation with all styles/script links no longer working, see my next post for details.

Nov 19, 2011 at 9:55 PM

Hi sa302

I am having the same situation.
I found out, that putting the <location> tag just around <system.webserver> makes the virtDirs work.
But when I use this line

<location path="." inheritInChildApplications="false">

then it brakes the layout of Orchard. Or better: there is none at all. just html.
Could you tell me how you exactly you achieved the working virtDIrs? What syntax did you use and did you use additional web.config files in the virtDirs?

Thanks a lot for your help!

Nov 21, 2011 at 9:23 PM
Edited Nov 21, 2011 at 9:27 PM

Actually now that you mention it, I have this same problem. I must have had the CSS cached for a bit so I thought everyone was working, but all my styles go away too. I am not sure why, when I inspect the html in the page I see the style sheet path is correct. The URL is properly prepending my virtual directory path to the URL for the scripts/.css/etc. Yet when I try to navigate to those actual resources it gives me an error.

When I try to navigate to the URL for any scripts or css files I get the following:

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Config Error  Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'StaticFile'
Config File \\?\C:\apps\OrchardTest\Core\Shapes\scripts\web.config

 

 <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />

This error happens only if you setup the main orchard web.config to be able to handle Vdirs. If you remove it, it works.
I am unsure why this is happening as I wasn't able to find any handler with the same name in the main web.config, but apparently it's a duplicate only if I am choosing not to inherit in child applications.

It would be great if bertrand or another coordinator could provide further assistance.

 

Coordinator
Nov 24, 2011 at 1:13 AM

I don't know. Maybe you need to remove first,maybe you need to change the name. Maybe IIS folks would have more insights on this.

Nov 24, 2011 at 6:29 AM

That's weird. I was sure I posted the answer... boy i am getting old.
Anyways - it works just fine. And yes, I needed the help off IIS folks.

The key is the "staticFile"-handler, which orchard doesn't like but the virtDirs need. Please see my (last) post here: http://orchard.codeplex.com/discussions/279590
There you find also the link to the thread in IIS forum, which is worthwhile reading, since it has some interesting links.

All the best

Nov 29, 2011 at 10:12 PM
Edited Nov 29, 2011 at 10:14 PM

Hi Ben, can you elaborate exactly what you did, your post is slightly unclear.

Are you saying I should be removing the staticFile handler from the orchard web.config and then adding that last in the root web.config of the vDir app?? Or inherit the handlers from IIS in my vDir app? How does one do that? I don't quite understand the link to IIS forums because I am not using php at all, though I imagine it's the same issue.

Also with your fix, did you still need the location tag or no?

Nov 29, 2011 at 10:55 PM

First of all - php has nothing to do with it. That was specific to my case.
The key is the staticfile handler and, if needed, any handler your virtDir specifically needs. If no special handler is needed (like php or aspx f.e.) you only need the staticfile handler (for a simple html page).

And it's actually quite simple:
1. no staticfile handler in the rootDir of Orchard. But that's no problem anyway since Orchard is taking care of that.
2. For every virtDir to work it needs the staticfile handler added in the web.config.

To make it little less theoretical, here is exactly what you should do: let take Orchard care of the rootDir and put the following web.config in the virtDir and it will work

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <clear />
            <add name="PHP_via_FastCGI" path="*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\php-cgi.exe" resourceType="Either" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <add name="StaticFile" path="*" verb="*" type="" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
        </handlers>
    </system.webServer>
</configuration>


you can delete the PHP line (or comment it out). I left it in, so you can see the order in which the handlers have to appear - static is last. But you can even leave the php inside - it does not hurt anything.
Look what happens on the IIS site under "handlers" in the management console. you will see those 2 lines being added.
And no location tag needed anywhere.

I would love to hear feedback. All the best

Coordinator
Nov 29, 2011 at 11:02 PM

Cool. Might be worth spinning into a documentation topic at some point.

Nov 29, 2011 at 11:43 PM

sure. I believe the more people are going to use orchard (and they will - it is by far the most modern/advanced CMS right now) the more people will inevitably stumble upon this topic. Could be handy to to have it somewhere easy to find.
if at some point you believe it might be worth it - just tell me what to put where and I would love to produce little "how to" or something similar.

Dec 1, 2011 at 6:16 PM
Edited Dec 1, 2011 at 6:23 PM

Well theben had a bit easier time implementing this solution since his vDir was using PHP, but I had a lot more trouble since all my vDirs were in .NET, and a different version of .NET. I was able to fix this first by doing theben's suggestions and a few extra steps, and then through a lot of trial and error I came up with a cleaner solution.

SOLUTION 1:

1. If your vDirs are using another version of .NET besides 4.0 (mine were): In the root Orchard web.config you need to put the <location inheritInChildApplications="false"> tag around the <system.web> tag because of the <compilation> tag having a targetFramework="4.0" attribute. If you don't add that location tag, it will break the vDirs since older .NET versions don't recognize that.

2. Add any handlers you need specific to your vDir application (mine is using Server 2008 64bit, so I had to add handlers for all the .NET extensions used in my app [such as .aspx, .ashx, etc.]). To see what handlers are supplied by default, go to any folder in the root of your site and click on "Handler Mappings" in the "Features View" on IIS 7, copy the ones for the extensions you need.

 

<system.webServer>
        <handlers>
                <!-- other handlers need for application -->
            <!-- for php -->
               <add name="PHP_via_FastCGI" path="*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\php-cgi.exe" resourceType="Either" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <!-- /for php -->
            <!-- for .NET -->
               <add name="PageHandlerFactory-ISAPI-2.0-64" path="*.aspx" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
              <!-- other .NET Handlers for .ashx, .asmx, etc. -->
           <!-- /for .NET -->
        </handlers>
</system.webServer>

 

3. Add the StaticFile handler to the vDir root web.config in <system.webServer> -> <handlers> tag:

<system.webServer>
        <handlers>
                <!-- other handlers need for application -->
            <!-- for php -->
               <add name="PHP_via_FastCGI" path="*.php" verb="*" type="" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\php-cgi.exe" resourceType="Either" requireAccess="Script" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
            <!-- /for php -->
            <!-- for .NET -->
               <add name="PageHandlerFactory-ISAPI-2.0-64" path="*.aspx" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
              <!-- other .NET Handlers for .ashx, .asmx, etc. -->
           <!-- /for .NET -->
               <add name="StaticFile" path="*" verb="*" type="" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
        </handlers>
</system.webServer>
You have to do this for every vDir application you have.

SOLUTION 2:

This way is a little bit cleaner I think because you only need to edit Orchard's root web.config with some additional sections, all your vDir apps should work as normal then as long as they would work with the server defaults.

1. In Orchard's root web.config Put the <location inheritInChildApplications="false"> tag around the <system.web> and <system.webServer> tags.

2. Immediately after that location tag (and before the runtime tag) put the following:

 

  <location path="Themes">
	<system.webServer>
		<validation validateIntegratedModeConfiguration="false" />
		<handlers accessPolicy="Script">
			<remove name="StaticFile" />
		</handlers>
	</system.webServer>
  </location>
  <location path="Core">	
	<system.webServer>
		<validation validateIntegratedModeConfiguration="false" />
		<handlers accessPolicy="Script">
			<remove name="StaticFile" />
		</handlers>
	</system.webServer>
  </location>
  <location path="Media">	
	<system.webServer>
		<validation validateIntegratedModeConfiguration="false" />
		<handlers accessPolicy="Script">
			<remove name="StaticFile" />
		</handlers>
	</system.webServer>
  </location>
  <location path="Modules">	
	<system.webServer>
		<validation validateIntegratedModeConfiguration="false" />
		<handlers accessPolicy="Script">
			<remove name="StaticFile" />
		</handlers>
	</system.webServer>
  </location>

 

This will allow all your vDirs to work as expected, but your Orchard installation won't be broken now.

Explanation:

The reason why this was happening is because inheritInChildApplications applies to child applications AND subdirectories. Therefore the <clear /> in the <handlers> of the root web.config would not be passed down to all the subdirectories. So when the subdirectory's web.config in, for example /Themes/SomeTheme/Styles/, would try to add the StaticFile handler, it would be a duplicate (because StaticFile is already a server default) and throw an error. This happened in any subdirectory where a .css or .js file was located. So by adding the path-specific locations above you are removing the server default StaticFile handler only in those directories, and then they are being re-added and are able to process the .css and .js files once again. The best thing about this method is that you can add new modules and themes and the default settings will be fine, as opposed to an alternative I considered (which had you removing the add StaticFile handler from all those subdirectory webconfigs, but that would have been very tedious and you'd have to do it every time you madded new themes/modules).

I would definitely put this in the documentation, I can't imagine it's so uncommon to want to use Orchard the your "main site" which consists of a lot of static/cms-handable stuff, but then custom applications as vDirs for specific/more custom stuff.

Coordinator
Dec 1, 2011 at 7:15 PM

This is great, thanks. I'll get all that into docs, giving you proper credit for the research.

Dec 1, 2011 at 8:13 PM

Nice! I was originally looking for solution 2 and never got it to work. Kudos.
I am glad this topic is now perfectly covered.

BTW, the problem with the different .Net versions I solved by converting the virtDir which used .Net into an Application and hence was able to choose a different .Net for the Application Pool of that App.

Dec 5, 2011 at 2:46 PM

Right, that is what I did to, but when you go from 4.0 to an older version, the <compilation> tag in <system.web> (or maybe it's just the targetFramework attribute of that tag) propagates from the orchard root config to the vDir, but 3.5 and older don't recognize it. So even if you set it to its own web app it will error.

Jan 16, 2012 at 2:25 AM
Edited Jan 16, 2012 at 2:26 AM

Sorry if my newb stupidity annoys anyone but I've never used IIS before.

Can anyone post what the contents of the root web.config should be? or is it specific to an individuals setup?

I have tried to implement the above solutions but I must be doing it wrong because it's not working.

I got all excited when the I deleted the root web.config and the subdirectories worked until I found Orchard to have stopped working :(

Jan 16, 2012 at 5:32 AM

don't delete the web.config. that is the config file for IIS and Orchard depends on that. You have to edit it according to the above guides.

Jan 16, 2012 at 10:28 AM

For solution 2, do I put <location inheritInChildApplications="false"> around all the <system.web> and <system.webServer> tags?

Jan 16, 2012 at 10:31 AM

yes, but read that example above carefully. it must look the same, otherwise it won't work.

You will have to test a little.

Jan 16, 2012 at 8:39 PM
Edited Jan 16, 2012 at 10:55 PM

Gave up trying to get it to work, didn't know what to look for. Will try another CMS
Mar 29, 2012 at 8:46 PM

Looks like I am (or we are) not the only persons having the problem:

 

[21:16] <x> i need to find an answer on something like that
[21:17] <x> on my old site I had a directory (folder) in my www root like
[21:17] <x> site.com/myfolder
[21:17] <x> but after I installed orchard, my folder was not accessible anymore
[21:17] <x> I would like to know if it is possible to let me create my own folders again in the www root where orchard lives.
[21:19] <choh> I am able to manually set the permalink to something like mysite.com/sales/home and then point to that, but that seems like a kludge.
[21:19] <x> it would be nice if orchard added a default directory like "publicfolders" or something like that
[21:19] <x> which act as a normal www-root
[21:20] <choh> Great minds think alike. :) I just saw a thread in the forums discussing subfolders.

 

For me this is also another reason to reconsider using orchard because it broke lots of our existing url structures which contains folders that cannot be moved.

May 9, 2012 at 10:16 AM

"1. In Orchard's root web.config Put the <location inheritInChildApplications="false"> tag around the <system.web> and <system.webServer> tags."

When I try to do this I get an intellisense error here;

<location inheritInChildApplications="false">

   <system.web>

Saying that

The "inheritInChildApplications attribute is not allowed 

Anyone know what's wrong?

May 9, 2012 at 4:12 PM

To answer my own question, it seems that this error is just and intellisense issue. It doesn't cause any errors...

May 9, 2012 at 6:21 PM

I have tried this approach and it seems like the sub application is working, but Orchard is still giving errors as described above, where it can't find the theme files etc.

Perhaps I misunderstood part of the instructions above.

This is my web.config, can someone see where I went wrong?

<?xml version="1.0" encoding="utf-8"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Enabled" value="true" />
    <add key="log4net.Config" value="Config\log4net.config" />
  </appSettings>
  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
        <add namespace="System.Linq" />
        <add namespace="System.Collections.Generic" />
        <add namespace="Orchard.Mvc.Html" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
  <!-- 
        Set default transaction timeout to 30 minutes so that interactive debugging 
        is easier (default timeout is less than one minute)
  -->
  <system.transactions>
    <defaultSettings timeout="00:30:00" />
  </system.transactions>
  <location inheritInChildApplications="false">
    <system.web>
      <!--<trust level="Medium" originUrl="" />-->
      <httpRuntime requestValidationMode="2.0" />
      <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
    -->
      <compilation debug="true" targetFramework="4.0" batch="true" numRecompilesBeforeAppRestart="250" optimizeCompilations="true">
        <buildProviders>
          <add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProviderShim" />
        </buildProviders>
        <assemblies>
          <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
          <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
          <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
          <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
          <remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <remove assembly="System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <remove assembly="System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <remove assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <remove assembly="System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <remove assembly="System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <remove assembly="System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <remove assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <remove assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <remove assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </assemblies>
      </compilation>
      <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
    -->
      <authentication mode="Forms">
        <forms loginUrl="~/Users/Account/AccessDenied" timeout="2880" />
      </authentication>
      <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
    -->
      <customErrors mode="Off" />
      <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
        <namespaces>
          <add namespace="System.Web.Mvc" />
          <add namespace="System.Web.Mvc.Ajax" />
          <add namespace="System.Web.Mvc.Html" />
          <add namespace="System.Web.Routing" />
          <add namespace="System.Linq" />
          <add namespace="System.Collections.Generic" />
          <add namespace="Orchard.Mvc.Html" />
        </namespaces>
      </pages>
      <httpHandlers>
        <!-- see below -->
        <clear />
        <add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
      </httpHandlers>
      <httpModules>
        <add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.0.20, Culture=neutral" />
      </httpModules>
    </system.web>
  </location>
  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
  <location inheritInChildApplications="false">
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WarmupHttpModule" />
      <add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.0.20, Culture=neutral" />
    </modules>
    <!-- Prevent IIS 7.0 from returning a custom 404/500 error page of its own -->
    
        <directoryBrowse enabled="true" />
        <defaultDocument>
            <files>
                <clear />
                <add value="Default.asp" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="default.html" />
                <add value="index.asp" />
                <add value="index.aspx" />
                <add value="index.php" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
            </files>
        </defaultDocument>
        <httpErrors errorMode="Detailed" />
        <handlers>
            <remove name="ASP.NET Wildcard" />
            <add name="ASP.NET Wildcard" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
        </handlers>
  </system.webServer>
   </location>
  <location path="Themes">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <location path="Core">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <location path="Media">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <location path="Modules">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="App_Data/Dependencies" />
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="3.0.0.0" />
        <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Coordinator
May 9, 2012 at 6:25 PM

What errors?

May 10, 2012 at 9:22 AM

Basically the layout of Orchard completely falls apart because all css files and js files are now 404ing.

As a part of the 404 message it also says:

"The resource you are looking for does not have a handler associated with it."

The request path and physical URL are correct, so I guess it's something to do with handlers.

I'm a little out of my depth here, as I don't know IIS terribly well...

Can anyone see what I'm doing wrong?

May 10, 2012 at 9:57 AM

By removing what it was suggested should be added for solution2 above, I have been able to get rid of all errors except one.

I removed this part:

<location path="Themes">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <location path="Core">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <location path="Media">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>
  <location path="Modules">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>

and now all seems to be working except for requests for a few png images that reside on this path:

http://localhost:8088/Media/Default/images/NEW%20BOOK%20VCVS4.png

For these I get a 500.19 error

 

Since this relates to the media folder, I tried to put:

<location path="Media">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <handlers accessPolicy="Script">
        <remove name="StaticFile" />
      </handlers>
    </system.webServer>
  </location>

...back in and now I get the 404 error again:

The resource you are looking for does not have a handler associated with it.

Coordinator
May 12, 2012 at 9:47 PM

500.19 means that you are trying to override a setting that has been locked at a higher config level or that you can't set at this level for some reason (usually that's application-level settings at directory level). If you can give more than the status code, such as the full error message, it would help.

Nov 15, 2012 at 9:39 AM

Hi, I followed the configuration specified above and when I access my virtual folder http://<Orchard Installation Folder>/blog I got a 403 Error, but when I access my orchard website everything was fine.

Access to the webpage was denied. You are not authorized to access the webpage at http://192.168.233.251/blog. You may need to sign in.

HTTP Error 403 (Forbidden): The server refused to fulfill the request.

I checked Orchard installation directory and my Virtual Directory (blog) permissions, user II_USRS has all permissions except Full Control/Special Permissions checked. Is there anything else that I am missing?

Nov 15, 2012 at 9:48 AM

My mistake, I haven't include <system.webServer> under <location path="." inheritInChildApplications="false">.

Mar 20, 2013 at 10:42 AM
I am creating a website with Orchard 1.6 and i need to host a simple .NET web app in the Orchard site.
After adding the web.config modifications from solution 2 it all seems to work fine.
The only things I'm missing are some images from my Theme folder (background, logo image, etc.).
This only happens when I use IIS for the Orchard site with the modified config.
When I use the Visual Studio (2012) Development Server the images are displayed correctly with the modified config.

I think that there's some configuration missing but after trying a lot of things I can't find it.
I've created a new site in IIS with a own AppPool for the Orchard site.

Does anyone recognize this problem and/or know a solution to fix this?
Jul 26, 2013 at 11:37 AM
I would also put system.web.webPages.razor under <location path="." inheritInChildApplications="false"> in order to be able to host an application under Orchard's virtual directory.
Sep 25, 2013 at 7:39 PM
Edited Sep 25, 2013 at 7:39 PM
Thank you so much sah302! Solution 2 saved my day!
Apr 25, 2014 at 7:02 PM
This worked for me as well.. up to a point.

I created a sql membership provider authentication module for orchard, which works great. But my child virtual app is a asp.net 4.0 forums site that also uses the same sql membership provider with the goal being a single sign-on via Orchard parent site logon; this arrangement has worked well in the past with prior asp.net 4.0 parent site. I'm assuming the orchard web.config edits above preclude this, though, as the orchard membership section is now contained in the location tag that prevents inheritInChildApplications(?).

Any thoughts on how I might get them to share the same SMP via SSO?

Thanks in advance for any tips on this!