Priya Avanigadda

Priya Avanigadda

  • NA
  • 87
  • 8.3k

Route specific response compression in dotnet core 2 asp.net

Oct 4 2019 5:54 AM
Hi All,
I am doing the response compression using GZip provider, I wrote the below code in Startup.cs class 

services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<GzipCompressionProvider>();
});
services.Configure<GzipCompressionProviderOptions>(options =>
{
options.Level = CompressionLevel.Fastest;
});

By using the above code, for all API endpoints, the response will be compressed since I have added the above code in startup class, but I want to compress the response only for one endpoint rather compressing for all endpoints.
so can anyone help me how to do only for the specific API controller endpoint?