Skip to main content

Enabling dynamic compression in IIS

A few years ago I blogged about enabling gzip compression for ASP.NET MVC applications; https://bartwullems.blogspot.com/2013/03/enable-dynamic-compression-for-aspnet.html.  I ended my blogpost with the following remark:

‘Maybe it should work too if you add this to your web.config, but I couldn’t get this working’

This week I had to configure dynamic compression again, so I decided to search for a solution(again).

When scrolling through the applicationHost.config file I noticed the following section:

<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />

Notice that there are 2 attributes defined on the httpCompression section; overrideModeDefault and allowDefinition.

From the documentation:

The overrideModeDefault attribute is an optional attribute that defines the locked state of a section. Its available values are either Allow or Deny. The default value is "Allow". All IIS sections that are related to any performance, security or critical aspect of the server are locked with this attribute set to "Deny". If the overrideModeDefault attribute is set to "Deny", then any configuration files at a lower level (i.e. web.config files) that set a value for a property for the specific configuration section are not able to take effect and override the global values. This incurs in a lock violation and an error occurs.

The allowDefinition attribute is another optional attribute that defines the level of the hierarchy in which the section can be defined and properties can be set. If its value is MachineOnly, then the section can be set only in applicationHost.config or machine.config. If its value is MachineToRootWeb, then the section can be set either in the MachineOnly files or also in the root web.config. If its value is MachineToApplication, then the section can be either set in all the previous three files or also in web.config files in the application root folder. And lastly, if its value is Everywhere (which is the default) it can be set in any configuration file, whether the ones that affect configuration globally or in web.config files that apply to a given site, application or virtual directory.

This explains why setting this configuration in the web.config file didn’t work. This specific section is locked at IIS level.

If you still want to override it in your web.config, you can alter this section to:

<section name="httpCompression" allowDefinition="Everywhere" overrideModeDefault="Allow" />

Popular posts from this blog

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Kubernetes–Limit your environmental impact

Reducing the carbon footprint and CO2 emission of our (cloud) workloads, is a responsibility of all of us. If you are running a Kubernetes cluster, have a look at Kube-Green . kube-green is a simple Kubernetes operator that automatically shuts down (some of) your pods when you don't need them. A single pod produces about 11 Kg CO2eq per year( here the calculation). Reason enough to give it a try! Installing kube-green in your cluster The easiest way to install the operator in your cluster is through kubectl. We first need to install a cert-manager: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml Remark: Wait a minute before you continue as it can take some time before the cert-manager is up & running inside your cluster. Now we can install the kube-green operator: kubectl apply -f https://github.com/kube-green/kube-green/releases/latest/download/kube-green.yaml Now in the namespace where we want t

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B