【问题标题】:Could not load file or assembly 'System.Web.Http.WebHost'无法加载文件或程序集“System.Web.Http.WebHost”
【发布时间】:2014-11-27 09:29:12
【问题描述】:

将 MVC 网页部署到我的 IIS 后,我收到以下错误:

Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 

我已进行以下更改以防止出现此问题:

  • 为 webhost 设置 Copy Local = True
  • 从 nuget 添加了 WebApi 2.2
  • System.Web.Http.WebHost 存在于 bin 文件夹中
  • 我的 web.config 有以下dependentAssembly:

代码:

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
  </dependentAssembly>

我仍然得到错误,我做错了什么?

【问题讨论】:

标签: c# asp.net-mvc iis


【解决方案1】:

您可能需要检查“views”文件夹中的 Web 配置,如果您有一个,以确保它具有正确的绑定重定向,就像您在主 Web 配置中所做的那样。

【讨论】:

    猜你喜欢
    • 2016-08-07
    • 2013-12-17
    • 2017-03-07
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    相关资源
    最近更新 更多