ASP.Net Core is an open source, cross-platform, lean, and modular framework for building high-performance web applications. You can run ASP.Net Core applications on Windows, Linux, and even MacOS. A thoroughly modern web framework, ASP.Net Core has built-in support for response compression, allowing you to reduce the size of responses and shorten response times. In this article we will examine how response compression works and how we can take advantage response compression middleware in ASP.Net Core.
Compression is an easy way to reduce network traffic and increase the speed of communication between web server resources and clients or consumers. The two popular algorithms available to achieve this compression include Gzip and Deflate, and most modern-day web browsers support response compression. The ASP.Net Core response compression middleware uses Gzip compression by default.
We will implement response compression using middleware. Note that the application pipeline in ASP.Net Core contains a series of request delegates that are invoked sequentially. We will take advantage of one of these middleware components to implement request compression. The middleware pipeline is configured using the Configure method in the Startup.cs file. This is where you can chain together your ASP.Net Core pipeline. We will discuss this further in the sections that follow.
Create an ASP.Net Core application
Assuming that you’re running Visual Studio Community Edition 2017 and .Net Core is already installed, follow these steps to create your first ASP.Net Core application in Visual Studio.