August 2017
Intermediate to advanced
330 pages
7h 26m
English
ASP.NET Core provides a middleware to compress the response before sending it back. This middleware provider compresses different MIME types, for this example we are interested in JSON data.
This package Microsoft.AspNetCore.ResponseCompression is included as part of .NET SDK, interestingly we need not work at controller or action level, just include this middleware in HTTP pipeline processing.
Be default, a GZIP compression provider is used; we can use other compression providers or write our own.
Open the Startup class and make changes as follows in the ConfigureServices and Configure method:
public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(); services.AddMvc(); ...Read now
Unlock full access