Posted by Anuraj on Wednesday, October 26, 2016 Reading time :1 minute
This post is about using Response Compression Middleware in ASP.NET Core. Long back I wrote blog post on Enabling GZip Compression in ASP.NET5. It was a custom middleware I implemented in DNX days. Now as part of ASP.NET Core 1.1 Preview 1, Microsoft introduced Response Compression Middleware in ASP.NET Core.
To use Response Compression Middleware, first you need to add the
Microsoft.AspNetCore.ResponseCompression package to your project.json file.
You can enable compression using the
ConfigureServices methods in the Startup.cs file.
Now you can restore the packages using
dotnet restore command, and run the application using
dotnet run command.
You can verify GZip compression enabled or not using Chrome developer tools. You can able to see something like this.
You can find more features and details about ASP.NET Core 1.1 Preview 1 release here
Happy Programming :)
What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.