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:
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)