I\'m attempting to add Gzip middleware to my ASP.net core app.
I have added the following package :
\"Microsoft.AspNetCore.ResponseCompression\"
To Enable GZIP in .net core 2.*
1. Install Microsoft.AspNetCore.ResponseCompression
with Install-Package Microsoft.AspNetCore.ResponseCompression
command or nuget package manager.
2. Add the following code into Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseResponseCompression();
app.UseMvc();
}
public void ConfigureServices(IServiceCollection services)
{
// Configure Compression level
services.Configure(options => options.Level = CompressionLevel.Fastest);
// Add Response compression services
services.AddResponseCompression(options =>
{
options.Providers.Add();
options.EnableForHttps = true;
});
}