I am unable to get Gzip compression middleware to work in asp.net core 2.0 (or 2.1). I created a new project using the "Blank" Web Application template and have the following code in Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddResponseCompression();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseResponseCompression();
app.Run(async (context) =>
{
context.Response.Headers.Add("Content-Type", "text/plain");
await context.Response.WriteAsync("Hello World!");
});
}
I verified that Chrome is sending "Accept-Encoding: gzip, deflate, br" in the request.
However, the server is not gzip-encoding the response:
What am I doing wrong?
I found this discussion, and tried everything from there, but it didn't help.