Unrecognized attribute ‘targetFramework’

I just installed the 4.0 framework on two servers and then had VS 2010 upgrade a test site from 3.5 to 4.0. When I tried accessing the site in my browser I got the error message Unrecognized attribute 'targetFramework'. The solution appears to be simple, just right-click the site in IIS, switch to the ASP.Net tab and change the framework to the 4.0 framework. Unfortunately for me our servers are 64-bit but are running IIS in 32-bit compatibility mode (Enable32bitAppOnWin64) because of some 3rd-party COM components. And because of this the ASP.Net tab apparently doesn’t show up in IIS. (And in fact the 32-bit version of AspNetMmcExt.tlb which controls that tab doesn’t even get installed which makes a little sense I guess.)

So without the ASP.Net tab how do you set the site’s framework version? Pretty easily, luckily.

First you need to find out your site’s IIS ID. Launch IIS Manager, click on Web Sites and look for your site’s Identifier in the right-hand panel. In my case its “1966841543”.

Next, drop to a command-line and navigate to the directory of the framework version that you want to use, in my case C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

Finally, run the following command substituting your site’s ID as needed:
aspnet_regiis.exe -s W3SVC/1966841543/ROOT

In my case I was only testing a sub-site so I actually ran:
aspnet_regiis.exe -s W3SVC/1966841543/ROOT/V2

  • Will

    You’re going on my Christmas card list for this one.

  • Dude you are awesome thanks so much for sharing!!!

  • Thanks for such a nice post.
    It helped me a lot
    Thanks again

  • Paul

    Thank you for the answer to a very obscure problem….I can’t imagine how much time this post has saved me!

  • fabio

    Obrigado cara….me salvou.

  • Phar

    Thank you very much for the extremely informative page. I searched and searched and finally your site resolved the issue. I pretty much knew what was going on but could not find the syntax to register 4.0 for the website, it kept trying to run under 2.0


  • After almost 40 article i found your solution and it worked for me… thanks a lot..

  • Tek

    Almost a year later and this is still a valid, working solution. Thanks.