在 Web 服务器上部署 MVC 5.1 应用程序

在 Web 服务器上部署 MVC 5.1 应用程序

我使用 MVC 5.1 技术制作了 ASP.NET 应用程序并尝试将其部署在 Winhost 服务器上。当我访问我的网站时,我收到以下错误消息。

Could not load file or assembly 'System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

版本信息:Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.0.30319.3400

固定的: 问题出在根文件夹 web.config 文件和本地 web.config 中。我们需要添加 MVC 程序集。

<system.web>
<trust level="Full"/>
<customErrors mode="Off"/>
<authentication mode="None"/>
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" maxRequestLength="65536"/>
<compilation targetFramework="4.5" batch="true" numRecompilesBeforeAppRestart="250" optimizeCompilations="true" debug="true">
  <assemblies>
    <add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
  </assemblies>
</compilation>

答案1

如果你已经安装了 .Net 4.5,那么这个帖子可能会给你正确的答案。只需将所需的程序集复制/发布到 bin 文件夹即可。Phil Haack 多年前撰写的文章据我所知仍然有效。

相关内容