Can I host a .net 2.0 virtual directory on asp.net 4.0?

We had no problems running the .NET 4.0 virtual directories on 2.0 websites, but the return path gives us some problems. This is understandable, but is there a way around this problem? They work with different application pools ... can we make the virtual directory skip the web.config website and go directly to the machine.config file?

We get the following error:

Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. Source Error: Line 22: </appSettings> Line 23: <system.web> Line 24: <compilation debug="true" targetFramework="4.0" /> Line 25: <customErrors defaultRedirect="url" mode="RemoteOnly"> Line 26: <error statusCode="404" redirect="~/404.aspx"/> 
+7
source share
3 answers

Add the following to your web.config root directory:

 <location path="." inheritInChildApplications="false"> 
+10
source share

Is it possible to completely exclude the "higher" web.config in a subfolder?

In the root folder of web.config:

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

(Ben got to this first, but I will leave this answer as it points to several alternatives)

+5
source share

This is a web.config inheritance problem, and you cannot overcome all problems with the <location> directive.

We received similar errors regarding duplicate configuration directives in one of our applications. After research, it looks like this because of this problem .

In short, our root site is ASP.NET 3.5 (this is 2.0 with specific libraries added), and we have a helper application, which is ASP.NET 4.0.

Inheriting web.config forces the ASP.NET 4.0 sub application to inherit the web.config file of the parent ASP.NET 3.5 application.

However, the ASP.NET 4.0 application is global (or "root") web.config, which is located in C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Config \ web.config and C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Config \ web.config (depending on your bitness) already contains configuration sections that are present in the web.config application of the .NET 3.5 application.

Then the ASP.NET 4.0 application tries to combine the root ASP.NET 4.0 web.config and the parent web.config (the one used for the ASP.NET 3.5 application), and works with duplicates in the <configSections> node.

The <location> directive cannot be used to prevent the inheritance of <configSections> entries. The only solution I could find was to remove configSections from the parent web.config, and then either

  • Determine that you do not need them in the root application, or
  • Upgrade the parent application to ASP.NET 4.0 (so that it can access the web.config root configurations)
+1
source share

All Articles