This project is read-only.

Virtual Directories stopped working

Topics: Administration, Troubleshooting
Nov 16, 2011 at 2:35 AM
Edited Nov 16, 2011 at 7:02 AM


on my homepage I have several virtual directories (f.e. /phpmyadmin). After I uploaded Orchard with Webmatrix they stopped working. Instead I get a "resource not found" error.

How can I reactivate those directories without Orchard interfering?

Thanks a lot for your help,


Nov 16, 2011 at 7:36 PM

It has something to do with the web.config file. when I replace it with the simple file below, orchard stops working but I can access the virtDirs again.

How do I need to edit the webconfig so I can user VirtDirs together with Orchard?

<?xml version="1.0" encoding="UTF-8"?>
        <directoryBrowse enabled="false" />
                <clear />
                <add value="index.html" />

Nov 16, 2011 at 11:06 PM

Yes, the Orchard config locks down everything. You need to reactivate things, for example by putting a web.config in your virtual directory, or by adding a <location inheritInChildApplications="false">

Nov 17, 2011 at 7:03 AM

Hi Bertrand and thanks a lot for your answer.

Here is what I tried:

1. I put the <location> before and after <system.web> in the web.config of orchard (I also tried before <system.web> and close after <system.webserver since I have seen this here:

2. I put the "small" (above) web.config in the virtual directory.

3. I tried the 2 above with different combinations (with web.config in virtDir and without, etc...)

Still, all the calls are being caught  by orchard, hence no virtDir.

Sorry for bothering with that, but there is no obvious and easy way to figure that out by myself (i am not a programmer) and I need those virtDirs.

Nov 17, 2011 at 7:13 AM

You can also restore settings in the web.config of the vdir.

Nov 17, 2011 at 8:00 AM

What do you mean by "restore"? phpmyadmin, roundcube,... are from the LAMP world - they don't have any web.config to "restore".

I put one there to test it (the small one from above with the <clear/> tag).

Is there no simple way to reactivate virtDirs? I mean virtDirs are not something out of space - they are very common.
Is this maybe the wrong forum (but in the IIS-forum they send me here)? Is web.config for programmers or IIS administrators? Who can help me?

Nov 17, 2011 at 8:39 AM

Yes they do. Web.config is not just ASP.NET, it's also IIS.

Nov 17, 2011 at 1:12 PM

somehow I am a little baffled: is this such a secret? a simple virtDir? Why am I not allowed to use one? Why do I have to find (and probably pay) a programmer who can fix this?
Literally EVERY other major CMS has no problem with that - why Orchard? What is the big deal here? I JUST WANT A SIMPLE VIRTUAL DIRECTORY TO WORK.

Why do I not get a straight answer - nowhere? I was hoping you could tell me the solution - since you programmed it!

Please: Just tell me the secret and tell me what to do exactly. I would terribly appreciate it! thank you.

Nov 17, 2011 at 3:20 PM
Edited Nov 17, 2011 at 3:21 PM

Edit: Sorry, I wrote a response but it was incorrect.

Nov 17, 2011 at 4:43 PM

I am glad that you say so. Let me tell you what the previous situation was:

One website with one index.html in root with one line of html code which displayed one single little .jpg.
There was in fact one web.config and (as you suggested) I do have a backup - please see my second post. As a matter of fact, when I "restore" this web.config the virtDirs do start to work again - but Orchard stops!
So, if I like or not (and believe me I do NOT like it) I have to change something in the web.config which Orchard copied into root (since Orchard obviously depends on particularly that one).

Question is: WHAT do I need to change there.

It is the original Orchard web.config (nothing changed) - what needs to be changed there so subdirs/virtDirs/Apps are working again. Since everything is default install: Simple situation - simple question.

AND: As Bertrand said, Orchard purposely locks down everything. I would love to know now how to open it again.

And sorry for my maybe annoyed tone - I really don't mean it that way. I am just stunned why literally no one can give me a straight answer to such a simple and straight question. I had expected that to be a "one poster".

Nov 17, 2011 at 4:58 PM

Well first off there are some assumptions being made - you assume it's a simple question with a simple answer, but since it's something I've personally never seen crop up after many months on these forums that might not be so. Additionally, Orchard is a very complex CMS and it does a lot of things to subvert the IIS pipeline in order to function properly and securely; this does sometimes cause conflicts with integrating other systems, and the answer may not be as immediately straightforward as you think. Finally you assume that virtual directories are simple, but realistically nothing in IIS is all that simple!

However, Bertrand has suggested what you probably need to do to unlock the security, which is place a Web.config in your virtual dir that unlocks security in that directory and below. IIS config works in a hierarchical fashion, you can override pretty much anything in Web.config at any level of the folder structure.

Beyond that, maybe you could provide more detail on how you set up the virtual directories; I mean, is this the native IIS system or some other module?

Nov 17, 2011 at 6:23 PM

I'm also slightly annoyed by the tone of this thread. I spend a lot of my time, really a whole lot, answering questions on these forums, so I take it a little personally when people scream at me for not answering fast enough or the way they would prefer. I just cannot solve every problem in details for everyone. That is simply impossible. What I can do, and what is a lot more efficient, is to point people in the right direction so that they can find the solution themselves. This way, I get to help more than one or two people a day, and hopefully they get an opportunity to learn a bit more than just the specific answer to the specific question they asked. Of course, when I *do* have a ready answer, I provide it, but in this case I don't. Of course, everybody assumes that their particular issue is trivial and has been solved many times before, but that simply is not the case.

But you know what the great thing is? Once you or somebody else figures it out, everyone can benefit from it.

Nov 18, 2011 at 9:21 AM

I found the cause of the problem: missing handlers.
The orchard web.config "cleared" all the inherited handlers and added one that's returning 404 of the MVC cannot find it. A virtDir is no part of the Orchard MVC hence the failure.
When I reverse to "inherit" it brakes the layout of the orchard site.

And I have no Idea what handlers I need where since there are hundreds of them.

Any suggestions how I get my handlers back without braking orchard? What handlers are needed specifically by orchard so it works?

And a question out of curiosity: why this setting in the first place?

Nov 18, 2011 at 8:27 PM

That's why the inheritinChildApplication looks more promising.

This is set-up this way for security.

Nov 18, 2011 at 8:51 PM

This other thread may be of interest:

Nov 21, 2011 at 2:41 PM
Edited Nov 21, 2011 at 10:24 PM

thanks a lot for your explanation and the very good link. I believe this topic will come up a lot.
At the end I was not able to figure out how to do it with the "location" tab but I found another way:

The specific handler which Orchard doesn't "like" is the "staticfile"-handler. So I set all the handlers to inherit from the server and then had to delete that single one on the orchard level.
In the virtDir I added that handler again BUT one very important thing: it has to be LAST in the list of handlers. For that to see, one has to switch to "ordered view" and move the handler down
(actually not last, but after the handler which handles that specific App).

Here the link to the post in the IIS-forum since it also has some very interesting links:

Thanks again for all your help and ideas and all the best.

EDIT: Actually you do not need to set to inherit. just add the correct handlers in the correct order (that gave me headache) in the web.config of the virtDir.

Feb 26, 2013 at 4:09 AM
theben, I had a similar problem that I was able to solve (with Bertrand's help, thank you!) using the StaticFileHandler that you referenced above. I found that adding the static file handler after the <clear/> caused .css files to stop being served, as you mentioned. I added a second instance of the StaticFileHandler with a path that handles .css files and now both orchard and my static .htm files are looking good. My changes to the web.config looked like this:
<handlers accessPolicy="Script">
      <!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->
      <clear />
      <!-- Return 404 for all requests via managed handler. The url routing handler will substitute the mvc request handler when routes match. -->
      <add name="static1" path="*.htm" verb="GET" type="System.Web.StaticFileHandler" resourceType="File" />
      <add name="static2" path="*.css" verb="GET" type="System.Web.StaticFileHandler" resourceType="File" />
      <add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script" />