Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responses not being dynamically compressed when hosting ASP.NET Core in IIS

I am hosting an ASP.NET Core application in IIS using Kestrel and the ASP.NET Core Server Hosting Bundle, and even though Dynamic Compression is enabled in IIS the responses are not returning back as compressed. Does anything need to be enabled within the application itself for dynamic compression to work or is there anything else within IIS that need to be enabled?

like image 633
Alan Low Avatar asked Oct 22 '25 20:10

Alan Low


1 Answers

Adding the following to the web.config helped, as it appeared that application/json wasn't being compressed based on the default settings in IIS:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <httpCompression>
         <dynamicTypes>
             <add mimeType="application/json" enabled="true" />
          </dynamicTypes>
      </httpCompression>
    </system.webServer>
</configuration>
like image 199
Alan Low Avatar answered Oct 25 '25 09:10

Alan Low