This project is read-only.

Virtual directory solution

Topics: Customizing Orchard
Sep 11, 2012 at 12:50 AM
Edited Sep 11, 2012 at 12:53 AM

At the conference I heard Brett Morrison from Onestop Internet, speak about their hybrid solution - they are using Orchard but they are also using existing web forms by configuring IIS. This is something that I have been looking for, and I haven't found a good example yet. Brett can you share the web.config settings to make this happen? I am sure I won’t be the only happy camper - happy to see it.

Sep 11, 2012 at 2:46 AM
Edited Sep 11, 2012 at 2:50 AM

The Main Orchard.Web Web.Config is pretty much the same as the one that comes with Orchard.  You can do your own diff and spot the differences.

The Web Forms Web.Config is where the cleverness comes in. I had to explicitly <clear> and add back the handlers needed (line 78) AND remove the Orchard page namespace (line 52).

For IIS, I setup a virtual directory application pointing to our web forms app. I had to have them both using the same App Pool.

We also have Web.Configs sprinkled in various static content directories that are just StaticFile handlers only – they really help with performance. You can find one in \src\Orchard.Web\Themes\TheThemeMachine\Styles.

Here's our web.configs and screenshots of our IIS setup.

Hope this helps. Maybe I'll blog about this and all the nuances of this setup.  There's more to it, including:

  • Rewrite Rules - for things like /checkout rewriting to /varv/store/os/checkout.aspx
  • Error Handling - for a common way to handle 404s
  • Path Rooting - we had to make sure we didn't use '/', but DID use '~' in our Web Forms app.



Sep 12, 2012 at 5:45 AM
Edited Sep 12, 2012 at 5:53 AM

I got it going after doing a couple adjustments – I will note them down for others and of course for me when I forget how to do it. Both of these fixes where inside the virtual directory's web.config file. The first one was to add a clear command in the namespaces tag


        <remove namespace="Orchard.Mvc.Html"/>

The second was to add 4 lines of code that remove 4 specific assemblies as shown below. 


	<remove assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/><remove assembly="System.Web.Abstractions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
	<remove assembly="System.Web.Routing, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
	<remove assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
	<add assembly="System.Design, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
	<add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
	<I left all the add assembly lines of code - just added the remove assembly lines of code>
Thanks, Brett. That paid for the conference.
Sep 27, 2012 at 6:29 PM


There is not much information on integrating MVC apps this way, so I am hoping it's similar. It's not clear to me whether all the steps involved are included here. Specifically, I can't get my head around rewrite rules (even using the Orchard Rewrite Module). Any thought or any notion of when a more detailed explanation would be available?


Sep 27, 2012 at 8:53 PM
Edited Sep 27, 2012 at 8:55 PM

Well Dino, as Clinton would say, I feel your pain. I too went through a lot of the posts and saw that people were having a frustrating time making this happen. Because it isn't really an Orchard issue (it's IIS) and because each situation is different you got to dig in and try many possibilities. At one point I thought I was on my way to becoming an expert in IIS. I would say that you need to understand that Orchard removes the handlers, and that the client (virtual directory) needs to add them back. From what Brett gave me I had to do some adjustments, which I wrote about above. When you actually look at the Handler Mappings in IIS you start to get a better picture of what is going on. Or, at least that is how it worked for me. How long have you been trying to make it work?


Sep 27, 2012 at 11:13 PM
Edited Sep 27, 2012 at 11:13 PM

Not very long I must admit. Was doing the research and it was all very confusing. Particularly the URL rewrite (I read one post from either a contributor or developer for Orchard on StackOverflow that said it was a matter of URL rewriting for MVC - but for the life of me I cannot figure it out). Been actually trying on and off for the last two days, so, again, not long at all. Thanks for the advice (and the Bubba quote :) ).

Sep 28, 2012 at 1:59 AM

I didn't need to do any URL rewrite do you have an existing site where you need to map the URLs or something?

Are you using a Host or company server or ? I got it to work but I had my doubts. Do you use the IIS manager?
If you do, go to your website and then go the icon named Handler Mappings.
This is how it looks for Orchard.


And this is how it looks for the Virtual Directory - only twice as much as what is showing. 


So I am glad someone gave this to me - cause I would have never been able to type all of that.
I am very grateful for the open source concept so I might as well contribute by passing this on.