0

I'm migrating a .NET 5.0.13 website to .NET 6, and am randomly getting "Failed to load resource: net::ERR_CONTENT_DECODING_FAILED" on some web pages. In one case, I could make the problem go away if I removed a couple of entries in a select list I was building, or by changing the underlying data in the database feeding the page.

Is anyone else seeing something like this?

I've used the Chrome debugger's network tab to look at what's being sent and a snippet looks like this:

      "content": {
        "size": 279890,
        "mimeType": "text/html"
      },
      "redirectURL": "",
      "headersSize": -1,
      "bodySize": -1,
      "_transferSize": 102,
      "_error": "net::ERR_CONTENT_DECODING_FAILED"
    },

How can I go about debugging this?

This is so random, I'm unable to produce a simple example, I'm afraid.

Thanks in advance!

------------ UPDATE -------------------------------

I believe the problem appears with VS2022, not .NET 6.

The problem was in our Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
...
services.AddResponseCompression(options =>
{
   options.EnableForHttps = true;
};

We should have just gone with the default (false). Enabling compression for https also creates a security flaw.

Interestingly, with the EnableForHttps set to true, I could get things to work by forcing the compression to be GZIP:

services.AddResponseCompression(options =>
{
    options.EnableForHttps = true;
    options.Providers.Add<GzipCompressionProvider>();
}); 

.. or Brotli with 'optimized'

services.AddResponseCompression(options =>
{
    options.EnableForHttps = true;
    options.Providers.Add<BrotliCompressionProvider>();
});


services.Configure<BrotliCompressionProviderOptions>(options =>
{
    options.Level = CompressionLevel.Optimal;
});

but we're just going to turn EnableForHttps off.

  • https://stackoverflow.com/questions/14039804/error-330-neterr-content-decoding-failed has some suggestions worth trying: check/disable gzip encoding, remove BOM, etc. – omajid Feb 03 '22 at 21:37
  • Thanks @omajid, this lead me to turn off compression (it wasn't doing gzip, but brotli). I also found that with compression on and setting the brotli option to optimized rather than fasted it also worked. We'll probably just leave it off as it is apparently a security flaw to compress https. I'll include details in my OP about how this is all done in the dotnet startup.cs after I've done some more testing. It also might not be changing from dotnet 5 to dotnet 6 that is causing the problem, but VS 2022. – Jeff Spindler Feb 04 '22 at 22:05
  • Glad you found the solution. Please consider posting it as an answer so that the question shows as answered when other people are searching. See https://stackoverflow.com/help/self-answer – sbridewell Feb 14 '22 at 07:45

1 Answers1

0

Needed to make changes to turn off compression as described.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 15 '22 at 15:20