This project is read-only.

Hosting an Orchard site in a subfolder

Topics: Troubleshooting
Feb 24, 2012 at 9:19 PM

We've created an Orchard blog site and added several images under the Media folder inside the project's folder.  When we run it locally in WebMatrix, we're able to see the images. 

However, when we publish it, we publish it to a location like, where the project is located in "subfolder".  As a result, we don't see any of the images because it's looking for them in a Media folder at the root level. 

Does anyone have any suggestions?  I've tried everything I can think of with no luck.  Thanks!

Feb 25, 2012 at 1:38 AM

Try to have the same configuration on your dev boxes and on the production site: if you have a vdir on the site, also have one with the same name on your dev box.

Feb 25, 2012 at 5:15 PM

Thanks for the reply, Bertrand.  We don't have any virtual directories.  We just created a new Orchard blog site using its default configuration, then published it in a location like

I tried moving our project to the subfolder locally, but then WebMatrix couldn't run it.

I think it's clear we're new to Orchard, so any advice is appreciated.  I found a workaround by copying the Media folder to the root level at the hosting site.  I also had to delete the web.config file in the Media folder for this to work.  But this is a workaround.  I'd really like the project to be self-contained.

Thanks again!


Feb 26, 2012 at 6:42 AM <- that subfolder thing here, that has to be a vdir, an IIS application of its own, not just a subdirectory, otherwise it is never going to work.

Apr 16, 2012 at 9:33 PM

Maybe that explains my problems on my brand new host....

Few noob questions:

1)  How would I set up that virtual directory? If I wanted to put in a sub dir on the root? I make alot of websites, and something I need to put them in subdirs to demo for clients.... Nothing being able to do so quickly is kinda impeeding my progress I guess.

2) Hopefully this isn't something I need to contact my host for every time? I dunno...

Apr 16, 2012 at 10:03 PM

It's fairly easy to do, and there are tutorials for it on the IIS web site. Whether you have to contact your hosting company depends on the hosting company.

Jul 31, 2012 at 8:39 AM

I’m having trouble with this as well. Has anyone actually got Orchard running successfully in a sub directory?


Here’s my setup: <-- ASP.NET MVC 3 app running on .NET 4 <-- Orchard 1.5.1


I have tried making /blog a virtual directory and also an application in IIS, both yield the same errors which appear to be related to the inheritance of web.config files.


Here’s what happens:

1.       Firstly, you will get 500 error in the browser with no actual error message and nothing reported in the log – not very helpful. I opened up IIS Manager UI and tried to open the application configuration, and discovered the following error:


There was an error while performing this operation.




Filename: \\?\C:\[path] \MyBlog\web.config


Line number: 13


Error: There is a duplicate 'system.web.webPages.razor/host' section defined


2.       At this point I tried to <remove> the sections and allow the child web.config (ie the Orchard web.config) to re-define them. This kind of gets you past the initial error…



    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

      <remove name="host" />

      <remove name="pages" />

      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />

      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />




Now IIS Manager is now happy to open the file, however...


3.       If you try and browse to the site you’ll get an ASP.NET error (at least there is an error message now):


Configuration Error


Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.


Parser Error Message: Section or group name 'system.web.webPages.razor' is already defined. Updates to this may only occur at the configuration level where it is defined.


Source Error:


Line 10: <configuration>

Line 11:   <configSections>

Line 12:     <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">

Line 13:         <remove name="host"/>

Line 14:         <remove name="pages"/>



So, while the IIS Manager UI seems ok with using <remove> for <configSections>, ASP.NET is not. This behavior seems to be verified by this bug on Connect: This bug is pretty old, but I assume the information in there is still valid.


So, now we’re left in a situation where we need to isolate our child app’s configuration, but we can’t do it because inheritance for configSections doesn’t work properly.


Also, it’s worth nothing that when you search for info about child app config file isolation, the general guidance is to wrap the parents <system.web> section under <location> section to scope the inheritance like this:

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






The problem is that you can’t wrap a <configSections> under a <location>, so you’re stuck.


This seems like a pretty straightforward scenario: I have an existing ASP.NET app, I want to install Orchard under a sub directory and use it for a blog. Has anyone managed to get this scenario to work?




Jul 31, 2012 at 4:29 PM

Why would you need the Orchard application to be *physically* under your other application?

Jul 31, 2012 at 6:34 PM

I wouldn't have it "physically" under there. Physically, I would deploy them side by side:

  • c:\inetpub\
  • c:\inetpub\Orchard

But when it comes to the URL structure, I want:

  • <-- ASP.NET MVC 3 app running on .NET 4
  • <-- Orchard 1.5.1

The primary reason for this is SEO benefits of running as a sub directory vs a sub domain. Here's an article where Matt Cutts says he prefers sub directories over sub domains.

Aug 2, 2012 at 1:10 PM

If you configured the Orchard directory to be an IIS application, configured it to use an integrated pipeline ASP.NET 4.0 application pool, this will work.

Aug 2, 2012 at 4:43 PM

Although maybe IIS gets confused and routes as part of That would be purely an IIS issue though. You might want to ask on IIS forums.

Aug 7, 2012 at 8:57 AM

I configured the Orchard directory to be an IIS application and to use the integrated pipeline, but this doesn't solve the issue.

The root of the problem seems to be the nature of how ASP.NET/IIS handles web.config file inheritance, and the fact there is no way to stop a sub-site from inheriting the config of it's parent.

That, in turn, creates a problem for Orchard and appears to block what should be a pretty standard deployment scenario.

Aug 8, 2012 at 9:55 PM

Watch out that the root configuration (web.config) does not block or change something in the 'Orchard' application.
Wht don't you refactor the root app to Orchard :-)

Aug 9, 2012 at 5:48 AM

"the fact there is no way to stop a sub-site from inheriting the config of it's parent"

Aug 9, 2012 at 6:58 AM

@geertdoornbos - there in lies the problem, I want to stop the config from inheriting to sub applications. It's not practical to refactor a large, complex application just so I can use Orchard for the blog. If that's my only option I'd go to Wordpress instead. Note that technically Wordpress will still have the config file inheritance issues, but since its a PHP app, it wont matter that my root file config is cascading down.


@bertrandleroy - the method that you describe doesn't work, since there are only certain parts of the config file that can be wrapped in a <location path =”.” inheritInChildApplications="false"> element. You can not wrap the <configSections> element and you can not <remove> elements from the <configSections> element in downstream config files.

Here are some posts that reference this issue:


I must not be the only person who's tried to use Orchard in this way.

Aug 10, 2012 at 4:08 AM

No you're probably not the only person. I've had Orchard in a subdirectory many times, and I've never had a problem if the Orchard directory was an IIS application, but I've never seen it with a root domain being a different app. I'm suspecting that your requests are actually handled by the application that points at the root. But as I said before, this is very probably purely an IIS issue, so you should ask this question on the IIS forums.

Aug 10, 2012 at 5:30 AM

I suspect the way this has worked for you previously is where the root application config did not conflict with the Orchard sub app config.

The root of this issue appears to be the way IIS handles config for ASP.NET apps, however, it's also specifically related to hosting an Orchard sub app underneath a MVC root app.

Aug 10, 2012 at 5:46 AM

So how does your root app's config differ from the default config?