Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 views
in Technique[技术] by (71.8m points)

asp.net - 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
RootMVCSitein
RootMVCSite[OTHERMVCFILESANDFOLDERS]
RootMVCSiteweb.config
RootMVCSiteForumApp
RootMVCSiteForumAppin
RootMVCSiteForumApp[OTHERFORUMAPPFILESANDFOLDERS]
RootMVCSiteForumAppweb.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...