WebAPI Gzip when returning HttpResponseMessage

Add these NuGet packages:

Microsoft.AspNet.WebApi.Extensions.Compression.Server
System.Net.Http.Extensions.Compression.Client

Then and add one line of code to App_Start\WebApiConfig.cs:

GlobalConfiguration.Configuration.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));

That will do the trick!

Details at:

  • NuGet package page
  • GitHub

**Updated after comment from @JCisar

Update for ASP.Net Core

Nuget Package is

Microsoft.AspNetCore.ResponseCompression

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)