unrecognized attribute 'targetframework' [duplicate]

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.


Solution 1:

Registering the framework with IIS is what worked for me:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i

Solution 2:

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.