azzlack / Microsoft.AspNet.WebApi.MessageHandlers.Compression

Drop-in module for ASP.Net WebAPI that enables GZip and Deflate support
Apache License 2.0
194 stars 54 forks source link

Not compressed in new ASP.NET MVC 5 app #55

Closed lkurylo closed 2 years ago

lkurylo commented 6 years ago

I have installed the Microsoft.AspNet.WebApi.MessageHandlers.Compression.Server package and added the handler

private static void RegisterMessageHandlers(this HttpConfiguration config)
        {
            config.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));
        }

Unfortunatelly, as I see in Fiddler, the compression is not enabled:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 17 May 2018 10:51:26 GMT
Transfer-Encoding: chunked

Is there something I have missed?

yanhua1012 commented 5 years ago

I have encountered the same situation as you. If I turn off the web protection function of antivirus or changed the the value of agent header in request, the compression works.