简体   繁体   English

ASP.NET MVC 5 web.config <system.web> 编译和httpRuntime错误

[英]ASP.NET MVC 5 web.config <system.web> compilation & httpRuntime error

When I deploy my mvc application to my IIS 7 server it has the following in the web.config file: 当我将我的mvc应用程序部署到我的IIS 7服务器时,它在web.config文件中有以下内容:

  <system.web>
    <compilation targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
  </system.web>

Having the compilation & httpRuntime tags in give me the following error: 有编译和httpRuntime标签给我以下错误:

Parser Error Message: The 'targetFramework' attribute in the element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, ''). 分析器错误消息:Web.config文件元素中的“targetFramework”属性仅用于目标4.0版及更高版本的.NET Framework(例如,'')。 The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. “targetFramework”属性当前引用的版本晚于安装的.NET Framework版本。 Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework. 指定.NET Framework的有效目标版本,或安装所需的.NET Framework版本。

So just for giggles I removed the compilation & httpRuntime tags and then the sites works perfectly! 所以只是为了咯咯笑,我删除了编译和httpRuntime标签,然后网站工作完美! The server has 4.5.1 on it. 服务器上有4.5.1。 I'm guessing this is something about the application pool, but it looks like the only options in the application pool are: No Managed Code, .NET Framework v2.0, .Net Framework v4.0. 我猜这是关于应用程序池的东西,但看起来应用程序池中的唯一选项是:No Managed Code,.NET Framework v2.0,.Net Framework v4.0。 There isn't an option for v4.5 or v4.5.1. v4.5或v4.5.1没有选项。 Right now it's set to v4.0. 现在它被设置为v4.0。

I didn't really understand what compilation and httpRuntime are used for and why they are even in my web.config as I didn't explicitly place them there. 我真的不明白编译和httpRuntime用于什么以及为什么它们甚至在我的web.config中,因为我没有明确地将它们放在那里。

There are two ways Microsoft updates .NET Framework: Microsoft更新.NET Framework有两种方法:

  • Side by Side Release, just like v1.1, 2.0, 4 并排释放,就像v1.1,2.0,4一样
  • Enhancement, just like 3, 3.5, 4.5 增强,就像3,3.5,4.5

That means when you install .NET 4.5 the v4.0 folder is just updated to contain the .NET 4.5 files. 这意味着当您安装.NET 4.5时,v4.0文件夹刚刚更新为包含.NET 4.5文件。

IIS only shows the Side by Side releases , not the enhancements. IIS仅显示并排版本,而不是增强功能。 Since 4.5 is an enhancement, it is applied to the framework folder of v4.0. 由于4.5是增强功能,因此它适用于v4.0的framework文件夹。 Thats also explains why you only see .NET Framework v2.0 and .Net Framework v4.0 as options under IIS application pool. 这也解释了为什么您只在IIS应用程序池中看到.NET Framework v2.0和.Net Framework v4.0作为选项。

As for the targetFramework attribute, its is only recognized for framework 4.0, not prior. 至于targetFramework属性,它只能在框架4.0中识别,而不能在之前识别。

The targetFramework attribute has two effects: targetFramework属性有两个效果:

  • It controls the Common Language Runtime's quirks mode behavior 它控制公共语言运行时的怪癖模式行为
  • It works as a shortcut that allows the ASP.NET runtime to infer a wide array of configuration settings 它作为一种快捷方式,允许ASP.NET运行时推断出各种配置设置

Removing the attributes did solve your issue, but it is not the healthiest thing to do. 删除属性确实解决了您的问题,但这不是最健康的事情。 I think you should check the server's registry for which framework updates are installed on the server, check if the website is also configured to work for framework 4. 我认为你应该检查服务器的注册表,了解服务器上安装了哪些框架更新,检查网站是否也配置为适用于框架4。

您只需要在IIS 7.5服务器中将.NET框架升级到版本4.5,使用服务器上的Microsoft Web安装程序软件执行搜索.NET,然后安装.NET框架版本4.5以及所有应用程序目标该版本将起作用

my problem was that the >NET version for me site defaulted to 2.0 when setting up the site. 我的问题是,在设置网站时,我的网站版本默认为2.0。 Changed it to 4.0 and site works 将其更改为4.0并且网站正常运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM