In this article I will explain with an example, how to resolve the following error in IIS Server.
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
 
 

Error

Server Error in '/' Application.

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
 
The following error occurs, when the targetFramework attribute has been set with 4.0 in the Web.Config file, but the Application Pool is running in 2.0 framework.
So, the targetFramework attribute is not recognized by specified framework.
<compilation debug="true" targetFramework="4.0"></compilation>
 
 

Solution

1. Open the Web.Config file and remove or comment the compilation node.
2. Then, open IIS Manager and click on the Website under Sites you want to change.
IIS: Unrecognized attribute targetFramework
 
3. Now click on Advanced Settings as shown below.
IIS: Unrecognized attribute targetFramework
 
4. In the Advanced Settings dialog window, click on the 3 dots on the Application Pool option.
IIS: Unrecognized attribute targetFramework
 
5. After clicking the three dots, the default selected version of Application pool is .Net CLR Version: 2.0 as shown below.
IIS: Unrecognized attribute targetFramework
 
6. Now, change the .Net CLR version: v2.0 to .Net CLR version: v4.0 from the DropDownList and click OK.
IIS: Unrecognized attribute targetFramework