45

Possible Duplicate:
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive

Firstly, let me say that I'm aware that this question has been asked a few times on this site - but the answers to all of these don't resolve my issue.

I'm seeing the following issue when I try to add a new managed handler in IIS7:

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

The environment is Windows Server Enterprise 2008 SP1 with IIS7 installed.

My application is using .NET 4.0. The .NET framework was installed after IIS:

I've tried/checked the following:

  • My app pool is using .NET 4.0 (I have one version of .NET 4.0 installed, no beta's etc.)
  • Ensured .NET 4.0 is registered correctly with IIS using 'aspnet_regiis.exe -iru'.
  • Recycled the app pool, rebooted the machine.
  • Completely uninstalled .NET 4.0, then re-installed it.
  • Removed the 'targetFramework' attribute - this just causes a crash elsewhere.

To me it looks like IIS is still referencing a previous version of .NET somehow, even though my app pools in IIS tell me they are using .NET 4.0.

My website loads fine, but I can't setup my custom image handler due to this issue.

I'd greatly appreciate any advice.

Thanks.

UPDATE

This is crazy.. I've completely rebuilt by environment from scratch:

  • Download 'Windows Server Enterprise without Hyper V SP1' from MSDN.
  • Install .NET 4.0
  • Install ASP.NET MVC 3
  • Add the 'Web Server' role - ensure App Pool is using .NET 4.0
  • Deploy my project

The same error occurs when I try to add a custom hanlder mapping. I'm either doing something incorrectly / completely stupid or there is some issue with IIS7 in this setup. IIS doesn't recognise the 'targetFramework' attribute from .NET 4.0, even though my app pool is set to use .NET 4.0.

If I use the command 'aspnet_regiis -lv', it tells me that only .NET 4 is registered with IIS.

Community
  • 1
  • 1
Jimmy Collins
  • 3,294
  • 5
  • 39
  • 57
  • You haven't mentioned trying this solution: http://stackoverflow.com/questions/5420094/unrecognized-attribute-targetframework-in-4-0-site-with-2-0-sub-folder – Rob Nov 10 '11 at 22:09
  • I had looked at that - my version of IIS is 7, and the Virtual Directory is definetely using .NET 4.0 (according to IIS at least). At this point I'm considering rebuilding the entire environment from scratch. – Jimmy Collins Nov 11 '11 at 09:37
  • What is the exact .NET version number shown in the Application Pool? Is it `4.0.21006.1`? Also could you show how does your web.config look like? – Darin Dimitrov Nov 20 '11 at 09:10
  • This issue may be resolved by 4.0.3. [You can check out the KB article here.](http://support.microsoft.com/kb/2599651) @ me and let me know if this fixes your issue, I may try to get a canonical question/answer for this error and close dupes. Thanks. –  Nov 28 '11 at 20:02

2 Answers2

64

Registering the framework with IIS is what worked for me:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i
kenik
  • 1,788
  • 13
  • 12
31

Do you have your site setup under the 'Default Web Site' site node or did you create a new site in IIS? If you created a new site, try going to the 'Default Web Site' and changing it's application pool from 'DefaulAppPool' to 'Asp.Net v4.0.' I know the 'Default Web Site' should have nothing to do with your site, but I've read that in some situations that helped resovle the issue. Also, in order to get your custom image handler working, try to use a configuration-free HTTP handler, with a .ashx file extention. This way you can get your image handler working (until you resolve this issue) without having to register it in IIS.

bbeny
  • 632
  • 1
  • 7
  • 18
  • It's a seperate site under IIS running on a different port. My Default web site is running under the same .NET 4.0 App Pool. One thing I just noticed is that under IIS -> .NET Compilation -> General -> Assemblies, all the assemblies seem to be point to version 2.0 – Jimmy Collins Nov 10 '11 at 17:36
  • 1
    I too have most IIS>>.NET Compilation>>General>>Assemblies pointing to version 2.0, while a few others are pointing to 3.0 and 3.5. This just identifies the .net version those assemblies built with. I am not sure this has anything to do with your issue. – bbeny Nov 10 '11 at 19:07
  • Thank you! This worked for me. Absolutely crazy. Is this a bug? – dav_i Sep 10 '13 at 10:00
  • 1
    Changing the ".NET Framework Version" for the application pool worked for me! – jeremysawesome Feb 17 '14 at 17:57