1

Windows Server 2003, IIS6.

We're trying to deploy a non-MVC ASP.NET web application as a subdirectory of an MVC application.

However the ASP.NET application in the subdirectory is failing with the message "Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified." which is bizarre because it's not an MVC application.

David
  • 111
  • 1
  • 5

3 Answers3

0

Need more information:

  1. Is the child (sub-folder) ASP.NET web application running in its own IIS Application, or in the parent's IIS Application?

  2. Where is System.Web.Mvc.dll deployed?

If #1 is false (i.e. same IIS Application) then the requirement for System.Web.Mvc is being inherited from the parent web.config.

Richard
  • 5,324
  • 1
  • 23
  • 20
  • 1. It's in its own application. We tried setting the folder as an application, and also moving the folder to a separate path and creating a virtual directory. 2. It's installed on the server, so it's in the GAC. – David May 09 '10 at 15:21
0

We wound up not solving this problem, because we ran into a different but related problem. Since the paths in our MVC application do not use file extensions, we had to install a wildcard mapping, which we believed would prevent the subdirectory website from functioning.

So we punted and moved the sub-application to a subdomain and added a redirect for that subdirectory in the parent application's routes.

David
  • 111
  • 1
  • 5
0

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.

Oliver
  • 311
  • 1
  • 5
  • 13