Microsoft.AspNet.WebApi.MessageHandlers.Compression icon indicating copy to clipboard operation
Microsoft.AspNet.WebApi.MessageHandlers.Compression copied to clipboard

Not compressed in new ASP.NET MVC 5 app

Open lkurylo opened this issue 6 years ago • 1 comments

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?

lkurylo avatar May 17 '18 10:05 lkurylo

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.

yanhua1012 avatar Dec 20 '18 03:12 yanhua1012