You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Windows Server 2022后VS2013应用缺System.Web.Http.WebHost如何快速修复

最快解决方法

该报错是Windows Server 2022默认未预装旧版本ASP.NET Web API对应的全局程序集导致,最快可通过以下步骤解决:

  • 打开VS2013中的项目,在解决方案资源管理器的「引用」目录下找到System.Web.Http.WebHost、System.Web.Http、System.Net.Http.Formatting三个依赖程序集
  • 依次右键每个程序集选择「属性」,将复制本地属性值改为True
  • 重新编译发布项目,将新的发布包部署到Windows Server 2022服务器即可生效

如果不方便重新发布项目,也可以直接在服务器上安装ASP.NET Web API 2.2 运行时,安装完成后重启IIS即可解决。

若修改后仍存在报错,可检查项目web.config文件的<runtime>节点下是否添加了正确的程序集绑定重定向,示例配置如下:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <!-- 可同步添加System.Web.Http、System.Net.Http.Formatting的绑定重定向规则 -->
</assemblyBinding>

内容的提问来源于stack exchange,提问作者Ukeme N

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 03:54:03