Show / Hide Table of Contents

    WebExtensions.AddGzipCompression(this IServiceCollection services, CompressionLevel compressionLevel) Method

    .NET Standard 2.x

    Adds the GZIP response compression service and specifies the compression level.

    Namespace: SnapObjects.Data.AspNetCore

    Assembly: SnapObjects.Data.AspNetCore.dll

    Syntax

     public static IServiceCollection AddGzipCompression(this IServiceCollection services, CompressionLevel compressionLevel);
    

    Parameters

    services Microsoft.Extensions.DependencyInjection.IServiceCollection

    The Microsoft.Extensions.DependencyInjection.IServiceCollection for adding services.

    compressionLevel System.IO.Compression.CompressionLevel

    The level of compression for the stream.

    Returns

    Microsoft.Extensions.DependencyInjection.IServiceCollection

    Returns the current Microsoft.Extensions.DependencyInjection.IServiceCollection object.

    Examples

    The following code demonstrates how to use the AddGzipCompression method in the ConfigureServices method of the Startup class to add the GZIP response compression service.

    using SnapObjects.Data.AspNetCore;
    using Microsoft.Extensions.DependencyInjection;
    using System.IO.Compression;
    
    namespace Appeon.ApiDoc.WebExtensionsExamples
    {
        public class Startup_AddGzipCompressionExample
        {
            // Uses this method to add services to the container.
            public void ConfigureServices(IServiceCollection services)
            {
                // Injects GZIP compression service and specifies the compression level 
                // to CompressionLevel.Fastest.
                services.AddGzipCompression(CompressionLevel.Fastest);
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon