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.

4
  • You haven't mentioned trying this solution: stackoverflow.com/questions/5420094/…
    – Rob
    Nov 10, 2011 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. Nov 11, 2011 at 9: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? Nov 20, 2011 at 9:10
  • This issue may be resolved by 4.0.3. You can check out the KB article here. @ 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.
    – user1228
    Nov 28, 2011 at 20:02

2 Answers 2

64

Registering the framework with IIS is what worked for me:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i
5
  • 4
    Note the > there, I mistook it for a complete path. Apr 4, 2014 at 10:33
  • 2
    I really don't understand why this should be necessary when you install IIS with asp.net as a selected feature :/
    – Ortund
    Sep 9, 2014 at 11:17
  • 3
    This did not work for me... same error, no change.
    – Ted
    Dec 11, 2014 at 11:59
  • that works for me as well May 4, 2016 at 10:19
  • Changing app_pool default to 4.0 and running "aspnet_regiis -i" solved it for me. Thanks!! Feb 14, 2018 at 18:05
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.

4
  • 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 Nov 10, 2011 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, 2011 at 19:07
  • Thank you! This worked for me. Absolutely crazy. Is this a bug?
    – dav_i
    Sep 10, 2013 at 10:00
  • 1
    Changing the ".NET Framework Version" for the application pool worked for me! Feb 17, 2014 at 17:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.