You are currently offline, waiting for your internet to reconnect

Runtime error when debugging a ASP.NET 2.0 IIS website that is a sub-web of an ASP.NET 4 IIS website

This article has been archived. It is offered "as is" and will no longer be updated.

If you use Visual Studio 2010 to create an ASP.NET 2.0 web application as a sub-web underneath an a web application that is targeting ASP.NET 4, your ASP.NET 2.0 application will not run. If you attempt to view the sub-web in your browser, it will show the following error:
"Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive."

If you try to debug from within Visual Studio, you will get:
"Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors."

In ASP.NET, by default a web application will inherit the configuration settings of its parent. In the case of an ASP.NET 2.0 web application that inherits from an ASP.NET 4 web application, the web.config section “<compilation debug="false" targetFramework="4.0" />” inside of <system.web> is inherited into the ASP.NET 2.0 sub-web. Because the ASP.NET 2.0 sub-web is automatically running under an application pool that is targeting .Net Framework 2.0 by Visual Studio, it uses the ASP.NET 2.0 runtime which does not understand the targetFramework attribute.
You can choose to have child applications not inherit the targetFramework attribute by placing the following inside of your parent application:

<location path="" inheritInChildApplications="false" >
        <compilation debug="false" targetFramework="4.0" />

Note that this will affect other applications that you expect to inherit these compilation settings.

Alterntiavely, you can:

  • Move your web site into a location in IIS whose parent targets the 2.0 framework
  • Change your parent web to use the 2.0 framework (Note: this may cause other web applications on your machine to stop functioning properly)
  • Target .NET framework 4 in the sub-web (Note: you will be unable to deploy this Web application to any machine without .NET Framework 4 installed)
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 2023222 - Last Review: 12/12/2015 07:51:37 - Revision: 3.0

Microsoft Visual Studio 2010 Professional, Microsoft Visual Studio 2010 Ultimate, Microsoft ASP.NET 4

  • kbnosurvey kbarchive KB2023222