C# Asp.net MCV4 框架问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12143777/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 22:14:55  来源:igfitidea点击:

Asp.net MCV4 framework issue

c#asp.netasp.net-mvc-4

提问by nermik

I made a web site using VS 2012 and MVC4, it is work my localhost but when i published and put my host it doesn't work. IIS confiurations are same. But it gives me this error lines:

我使用 VS 2012 和 MVC4 创建了一个网站,它在我的本地主机上工作,但是当我发布并放置我的主机时它不起作用。IIS 配置是相同的。但它给了我这个错误行:

This is error;

这是错误;

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: The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, '<compilation targetFramework="4.0">'). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework.

Source Error: 


Line 20:   </appSettings>
Line 21:   <system.web>
Line 22:     <compilation targetFramework="4.5" />
Line 23:     <httpRuntime targetFramework="4.5" />
Line 24:     <authentication mode="Forms">

Thank you for your advice in advance

提前感谢您的建议

回答by recursive

You have to update your application pool to .net 4.0 in IIS. It's probably set to 2.0 currently.

您必须在 IIS 中将应用程序池更新为 .net 4.0。它目前可能设置为 2.0。

回答by Brad Christie

Chances are IIS doesn't have 4 installed (or if it is the site isn't specified to use it). Assuming you're running IIS7 have a look at this post:

可能是 IIS 没有安装 4(或者如果没有指定站点使用它)。假设您正在运行 IIS7,请查看这篇文章:

回答by ikutsin

I had similar issue installing nopCommerce 2.80 on server. I use IIS7 net. 4.0 integrated pool. And just installed .net 4.5 from WebMatrix Products->Frameworks section. Restart will be required. Then it started to work.

我在服务器上安装 nopCommerce 2.80 时遇到了类似的问题。我使用 IIS7 网络。4.0 集成池。刚刚从 WebMatrix Products->Frameworks 部分安装了 .net 4.5。将需要重新启动。然后它开始工作。

回答by mariom64

Change this tag to 4.0:

将此标签更改为 4.0:

<compilation targetFramework="4.0" />

and remove this tag:

并删除此标签:

<httpRuntime targetFramework="4.5" />

回答by Xvegas

You just need to upgrade your .NET framework to ver 4.5 in your IIS 7.5 server you do that using the Microsoft web installerdo a search for .NET and then installed the .NET framework version 4.5 and the all the apps that target that version will work

您只需要在您的 IIS 7.5 服务器中将您的 .NET 框架升级到 4.5 版,您可以使用Microsoft Web 安装程序来搜索 .NET,然后安装 .NET 框架 4.5 版,并且所有针对该版本的应用程序都将工作

回答by Syed Zia

you have to install .net framework 4.5 then it will works fine. "targetframework" attribute is not recognized by .net framework 4.0. So run the following command on command prompt and check either .net version 4.5 in installed on hosting machine or not.if not then install .net framework 4.5.it will work fine. run this command on cmd as follows.

您必须安装 .net framework 4.5,然后才能正常工作。.net framework 4.0 无法识别“targetframework”属性。因此,在命令提示符下运行以下命令并检查主机上是否安装了 .net 版本 4.5。如果没有,则安装 .net framework 4.5。它会正常工作。在 cmd 上运行此命令,如下所示。

wmic /namespace:\root\cimv2 path win32_product where "name like '%%.NET%%'" get version

回答by felickz

Run this: Microsoft .NET Framework Repair Tool

运行这个:Microsoft .NET Framework 修复工具

  • Make sure you run in offline mode if you need to run against servers that are firewalled off from the internet.
  • 如果您需要在防火墙与 Internet 隔离的服务器上运行,请确保在离线模式下运行。