I have just encountered the same error for a different assembly in a very similar situation:
- IIS 8.5
- a site running an ASP.NET MVC application
- a virtual application underneath it, called
app
, in our case also an MVC app
In our case, though, the virtual application failed to load because Microsoft.Owin.Host.SystemWeb.dll
version 3.0.0.0
could not be loaded. We actually had version 3.0.1.0
sitting there but even with an assembly redirect in the web.config
this would not help. It was the root application that was using version 3.0.0.0
.
Running the virtual application underneath an empty site (simply pointing to an empty folder) worked, though. Also, running it as its own site worked as well.
Since I couldn't get the error fixed with the given setup, I came up with a different solution: hosting the root app as a virtual application, as well.
Now, this implied running inside a virtual folder, let's call it w
. The missing part in the puzzle was now a rewrite rule to map the site root to that virtual folder w
. I put this rule into a new web.config
file in the empty site root folder. This is what it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite / to /w" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="/w" logRewrittenUrl="true" />
</rule>
<rule name="Rewrite rest to /w/rest" stopProcessing="true">
<match url="^(/.*)$" />
<action type="Rewrite" url="/w{R:0}" logRewrittenUrl="true" />
<conditions>
<add input="{REQUEST_URI}" pattern="(^w$|^w/)|(^app/)" negate="true" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
As you can see, it's actually two rewrite rule because I couldn't quite get it to work with only one. In the second rule you can see that I exclude app
from rewriting because that's where my other application lives.
Here's what we have:
- requests for
www.mydomain.com
get rewritten to www.mydomain.com/w
and subsequently processed by our first virtual application w
which used to be our root application
- requests for
www.mydomain.com/app
are handled by our virtual application app
as expected
I'm currently still fighting with some static file paths not being properly rewritten, but I expect to get this fixed soon.