我在我的项目中安装了一个Microsoft ASP.NET Web API压缩nuget包,并在Register方法中添加了一行到WebApiconfig,如此链接所示https://www.nuget.org/packages/Microsoft.AspNet.WebApi.MessageHandlers.Compression /
GlobalConfiguration.Configuration.MessageHandlers.Insert(0, new CompressionHandler(new GZipCompressor(), new DeflateCompressor()));
Run Code Online (Sandbox Code Playgroud)
还将以下代码添加到web.config文件中
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误
错误1类型"System.Object"在未引用的程序集中定义.您必须添加对程序集'System.Runtime,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'的引用.d:....\App_Start\WebApiConfig.cs
编译器抱怨GlobalConfiguration类,上面有错误.我正在使用> .NET Framework 4.5
asp.net ×1