0
Answer

Route specific response compression in dotnet core 2 asp.net

Photo of Priya Avanigadda

Priya Avanigadda

5y
1.2k
1
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?

Answers (0)