Minimal APIs in ASP.NET Core allow you to easily create RESTful APIs with minimal code and configuration. No matter what type of API we build, it is always important to minimize the amount of data transferred over the network, which saves bandwidth and improves the responsiveness of the app. We do this by compressing the payloads of both requests and responses.
Of course, that means we must decompress those payloads at the other end. In ASP.NET Core 7, request decompression is supported out of the box: You can now use the new request decompression middleware to enable your API endpoints to accept requests that have compressed data.
This article examines how you can work with request compression and decompression in ASP.NET Core 7 Minimal APIs. (Note that we discussed response compression in ASP.NET Core in a previous article.) To use the code examples provided in this article, you should have Visual Studio 2022 installed in your system. If you don’t already have a copy, you can download Visual Studio 2022 here.