Asp.net core ASP.NET核心响应压缩不工作

Asp.net core ASP.NET核心响应压缩不工作,asp.net-core,asp.net-core-2.0,Asp.net Core,Asp.net Core 2.0,我有一个端点,它从文件加载json,然后返回其内容(ASP.NET Core 2.0): 在Chrome中点击该端点时,我得到以下网络数据: 现在,如果启用响应压缩,请求的大小会变大: 以下是我的ConfigureServices和Configure方法: public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(options =>

我有一个端点,它从文件加载json,然后返回其内容(ASP.NET Core 2.0):

在Chrome中点击该端点时,我得到以下网络数据:

现在,如果启用响应压缩,请求的大小会变大:

以下是我的
ConfigureServices
Configure
方法:

   public void ConfigureServices(IServiceCollection services)
   {
        services.AddResponseCompression(options =>
        {
            options.Providers.Add<GzipCompressionProvider>();
        });

        services.AddApplicationServices();

        services.AddDbContext<DatabaseContext>(...);

        services.AddCors();

        services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<DatabaseContext>();

        services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                ...
            });

        services.AddMvc().AddJsonOptions(options => { ... });

        services.AddAuthorization(options =>
        {
            ...
        });

        services.AddEntityFrameworkSqlServer();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseResponseCompression();

        app.UseCors(c => c.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());

        app.UseAuthentication();

        app.UseMvc(routes =>
        {
            routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
        });

        app.UseStaticFiles();

    }
public void配置服务(IServiceCollection服务)
{
services.AddResponseCompression(选项=>
{
options.Providers.Add();
});
AddApplicationServices();
AddDbContext(…);
services.AddCors();
services.AddIdentity().AddEntityFrameworkStores();
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(选项=>
{
...
});
services.AddMvc().AddJsonOptions(options=>{…});
services.AddAuthorization(选项=>
{
...
});
services.AddEntityFrameworkSqlServer();
}
公共无效配置(IApplicationBuilder应用程序,IHostingEnvironment环境)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseResponseCompression();
app.UseCors(c=>c.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
app.UseAuthentication();
app.UseMvc(路由=>
{
MapRoute(“默认值”,“{controller=Home}/{action=Index}/{id?}”);
});
app.UseStaticFiles();
}

我在这里遗漏了什么?

我遇到了同样的问题。任何压缩都可以工作吗?例如静态文件?
   public void ConfigureServices(IServiceCollection services)
   {
        services.AddResponseCompression(options =>
        {
            options.Providers.Add<GzipCompressionProvider>();
        });

        services.AddApplicationServices();

        services.AddDbContext<DatabaseContext>(...);

        services.AddCors();

        services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<DatabaseContext>();

        services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                ...
            });

        services.AddMvc().AddJsonOptions(options => { ... });

        services.AddAuthorization(options =>
        {
            ...
        });

        services.AddEntityFrameworkSqlServer();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseResponseCompression();

        app.UseCors(c => c.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());

        app.UseAuthentication();

        app.UseMvc(routes =>
        {
            routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
        });

        app.UseStaticFiles();

    }