Unrecognized attribute ‘targetFramework’ error is encountered for Asp.Net 4.0 site while Deploying it to the IIS or GoDaddy

This error is usually thrown when you try to deploy a Asp.Net 4.0 to IIS whose App Pool is targeting the .Net 2.0. You can confirm that by checking the last line of your error page. This is where running the .net version is displayed.

To resolve it, just do the following


Make sure .Net 4.0 is registered in IIS. To do that run the aspnet_regiis.exe tool from the command prompt having administrative rights.
The tool is located at C:\Windows\Microsoft.NET\Framework64\v4.0.30319.

Now in the command prompt run the command aspnet_regiis.exe -iru.

We’re using iru because it Installs this version of ASP.NET. If there are any existing applications that uses ASP.NET, it will not change IIS configuration to use this version. More Info

Next open IIS Manager. Go to your sites app pool. Select Basic Settings and change the framework from 2.0 to 4.0.

For GoDaddy

For GoDaddy, you have to select from the menu bar, More => IIS Management. There at the top you’ll see your sites current .net version with an option to modify.

Select it and change the .Net version from 2.0 to 4.0.

Now here’s an issue. Even if you see your version as 4.0/4.5 still, I recommend you to change the version first to 2.0 and then again back to 4.0. This issue has arisen in the past that the GoDaddy IIS is showing the .Net Framework as 4.0 but somehow internally, it’s still pointing to 2.0. You can confirm the version of the .net environment by looking at the last line of the error page [highlighted above] Just remember to manually recycle the app pool after each version change.

That’s it. The IIS is now targeting the framework .net 4.0.