简体   繁体   中英

One IIS site, Two applications with different .NET versions

I porting an old site into MVC 4 and I have it working so far. However there is also a third party forum which we use which isn't changing. In IIS 7 I created a new Application for the forum and it also has its own app pool (MVC is .NET4 and forum is .NET 2).

The applications are in different physical directories on the server, and here's what the IIS directory structure looks like with ForumApp being the sub-application:

\\RootMVCSite\\
\\RootMVCSite\\bin
\\RootMVCSite\\[OTHERMVCFILESANDFOLDERS]
\\RootMVCSite\\web.config
\\RootMVCSite\\ForumApp\\
\\RootMVCSite\\ForumApp\\bin
\\RootMVCSite\\ForumApp\\[OTHERFORUMAPPFILESANDFOLDERS]
\\RootMVCSite\\ForumApp\\web.config

However, when I go to the forum I get the following error:

Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

Line 20:   <system.web>
Line 21:     <compilation targetFramework="4.0" />

The confusing part is that it is looking in the web.config for the root MVC site rather than the forum site where the sub-application is pointing. What do I need to do in IIS or web.config to fix this? Is there a way to prevent the sub-app from looking at the root site's web.config?

I figured it out. By wrapping the offending configuration sections with the location tag, those settings would be ignored by any child applications.

<location path="." inheritInChildApplications="false">
  <system.web>
    <compilation targetFramework="4.0" />
  </system.web>
  ...
</location>

If there's anything I should be wary of regarding this solution, please chime in and suggest any improvements or advice!

Check the application pool for that site in IIS and make sure it targets .NET Framework 4.0. By default a new application pool will be set to .NET 2.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM