当我为 WebApi 安装 NuGet 包时,它为我提供了 System.Net.Http 的 1.0.0.0 版本,但它引用了版本 2。
我似乎无法为我的生活找到第 2 版。当我下载 .net 4.5 时,我得到 System.Net.Http 版本 4.0.315.x,但我不能使用它,因为 Web Api 程序集引用版本 2.0.0.0。
有人知道我在哪里可以找到这个版本 2.0.0.0 吗?我已经尝试过 NuGet 包管理器、mvc4、.net 4.5,但没有给我版本 2。
提前致谢。
当我为 WebApi 安装 NuGet 包时,它为我提供了 System.Net.Http 的 1.0.0.0 版本,但它引用了版本 2。
我似乎无法为我的生活找到第 2 版。当我下载 .net 4.5 时,我得到 System.Net.Http 版本 4.0.315.x,但我不能使用它,因为 Web Api 程序集引用版本 2.0.0.0。
有人知道我在哪里可以找到这个版本 2.0.0.0 吗?我已经尝试过 NuGet 包管理器、mvc4、.net 4.5,但没有给我版本 2。
提前致谢。
在节点下的 Web.config 文件中添加以下配置<system.web>(假设您的应用在 .NET 4.5 上运行,targetFramework属性设置为 4.5):
<compilation targetFramework="4.5">
<assemblies>
<add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
还在<configuration>节点下的根级别添加以下内容:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
这应该可以解决您的问题。