Unrecognized attribute 'targetFramework'. in 4.0 Site with 2.0 sub folder?

一个人想着一个人 提交于 2019-12-11 08:38:57

问题


I have recently upgraded a site to .net 4.0. I changed the app pool and almost everything is working properly.

However the admin section of the site which is in an 'admin' subfolder with its own web.config is still running under 2.0 for some reason. When I left click the sub directory in IIS and check the ASP.net tab of properties it get ASP.NET version 2.0.50727.

If i click 'Edit Configuration' I get this error "An error has occured attemping to read the configuration." The error message is:

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

The web config in the protected directly looks like this

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <authorization>
            <deny users="?"/>
        </authorization>
        <customErrors mode="Off"></customErrors>
    </system.web>
</configuration>

When I try to navigate to the admin section i get "Server Application Unavailable" and an entry in the app log complaining about two different versions.

Everything is running under the same app pool which is 4.0. Why is the sub folder not 4.0 and how do I fix it?


回答1:


What version of IIS are you running?

My guess, is that at some point, you (or somebody else) manually set the ASP.NET version to 2.0 on the subfolder.

The way it works... IIS checks to see if the value is not set. If it is not set, it inherits the value from the parent. Once the value is set explicitly changing the value at the parent does not cascade to the child.




回答2:


It sounds like you're using IIS6 in which case you'll have to right-click on your sub-directory and change the ASP.Net version.




回答3:


For some reason there was an entry for the admin folder in the IIS 6 Metabase. Using the IIS 6 Metabase explorer I was able to delete the ScriptMaps entry that had the data pointing to the 2.0 asapi .dlls.

This fixed my problem.



来源:https://stackoverflow.com/questions/5420094/unrecognized-attribute-targetframework-in-4-0-site-with-2-0-sub-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!