ASP.NET MVC4 到 5 升级

ASP.NET MVC4 to 5 Upgrade

我不得不从布满灰尘的盒子中取出一个非常古老的项目,并将其从 4 升级到 5,然后我按照 MS 站点 (https://docs.microsoft.com/en-us/aspnet/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2) 上的指导进行操作,这一切都在我的本地完美运行开发机。是的,它可以在我的机器上运行,所以请正确发货....

嗯,不,因为我发布到服务器,这就是问题开始的地方,因为我不断收到错误消息:

描述:处理此请求所需的配置文件时出错。请查看下面的具体错误详细信息并适当修改您的配置文件。

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, ''). 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.

我检查过 Web.Config 文件的目标设置为 4.7.1,服务器上的当前版本是 4.7.2,所以我哪里出错了。

Web.Config 中被引用的行是:

<compilation debug="true" targetFramework="4.7.1" />

并在错误页面的底部:

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2106.0

我太喜欢我的本地机器了,无法将它运送到云端,所以请有人帮忙。我已经用头撞桌子几个小时了,Google/Bing 等都没有用。

您是否尝试在服务器上安装 "Runtime" SDK?

可在此处找到适用于 Framework 4.7.1 的运行时 SDK:

https://www.microsoft.com/net/download/visual-studio-sdks

如果你还没有做过,试试吧!

可能您的托管服务器中没有 .Net 版本,只需在服务器中安装 .Net 版本即可。

.Net 4.7.1 Offline Installer

感谢您的回复,但此站点托管在共享托管平台上,因此我无法安装任何东西,但我检查过他们安装了 4.7.2。

我通过从编译设置中删除 targetFramework 解决了这个问题,并解决了问题。

旧:

<compilation debug="true" targetFramework="4.7.1" /> 

新:

<compilation debug="true" />

感谢您的帮助。现在进入下一期。