无法识别的属性“targetFramework”。需要注意的是属性名称是区分大小写的的是、属性、大小写、需要注意

2023-09-03 17:46:10 作者:好多狗 好多你 i

我刚刚上传了一个网站,我的服务器。它完美的作品在本地,但我上传后,网上的版本会显示这样的:

I have just uploaded a website to my server. And it works perfectly locally, but after I uploaded, the online version displays this:


Configuration Error    Description: An error occurred during the
processing of a configuration file required to service this request.
Please review the specific error details below and modify your
configuration file appropriately. 

 Parser Error Message: Unrecognized attribute 'targetFramework'. Note
that attribute names are case-sensitive.

Source Error: 



Line 37:     </buildProviders>
Line 38:     </compilation>
Line 39:     <httpRuntime targetFramework="4.0"
encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Line 40:     <machineKey compatibilityMode="Framework45" />
Line 41:  </system.web>


 Source File:  D:\HostingSpaces\o\o.com.au\wwwroot\web.config    Line:
39 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272

据本网站上其他的答案,因为它在服务器上的帐户设置为使用的.NET Framework 2.0。但是,这不是与我的情况,我确信,它设置为4.0,我已经甚至试图4.0集成。但它仍然显示此错误。

According to other answers on this site, its because the account on the server is set to use .NET Framework 2.0. BUT that's not the case with mine, I've made sure that it's set to 4.0 and I've even tried 4.0 Integrated. But it still displays this error.

什么引起的?我该如何解决这个问题?

What could be causing this? How can I fix it?

推荐答案

在应用程序试图使用的功能是新的ASP.NET 4.5(具体请参阅&LT;的httpRuntime&GT; &LT;将machineKey&GT; 元素),但服务器只有ASP.NET 4.0。删除&LT;的httpRuntime&GT; &LT;将machineKey&GT; 从Web.config中的元素来解决这个问题。

The application is trying to use features that are new to ASP.NET 4.5 (see in particular the <httpRuntime> and <machineKey> elements), but the server only has ASP.NET 4.0. Remove the <httpRuntime> and <machineKey> elements from Web.config to solve the issue.

(有趣的事实:在&LT;的httpRuntime / targetFramework&GT; 属性不存在,直到4.5因此,即使价值说4.0的服务器仍然因为失败它不希望看到这个属性的所有的。)

(Fun fact: the <httpRuntime/targetFramework> attribute didn't exist until 4.5. So even though the value says "4.0," the server still fails since it's not expecting to see this attribute at all.)