ASP.Net using wrong web.config for virtual directory

Alex Strasheim picture Alex Strasheim · Jul 24, 2012 · Viewed 7.3k times · Source

We're running IIS 6 on Windows Server 2003 R2.

We want to add a virtual directory that runs under .NET 4.0 to a site that runs under .NET 2.0. We've given the virtual directory its own app pool, and we've configured the virtual directory to run under 4.0.

The parent site works fine, but the virtual directory throws errors that reference the parent site's web.config file. We need the virtual directory to use its own web.config file.

The GUI in the IIS Manager says that the virtual directory is using its own web.config file, but the error messages we get refer to items in the parent's web.config file.

I'm not sure how to solve the problem. My best lead so far is from a post on another site said that the problem could be solved with something like this:

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

Again, I'm not sure this will fix things, and I'm not sure how to figure out where to put it or what it ought to contain. The parent site is built on top of a CMS system, and its web.config file is reasonably complex.

Answer

Alex Strasheim picture Alex Strasheim · Jul 25, 2012

I got this to work, so I want to leave the answer for the next person.

The location tags I mentioned in my question did the job. I got them to work by using them to enclose a system.web section:

<location path="." inheritInChildApplications="false">
  <system.web>
    .
    .
   (the stuff that made the site in the virtual directory break)
    .
    .
  </system.web>
 </location>