1
votes

I'm trying to determine the cause of a 500 server error I'm seeing in the diagnostics logs for my AspNetCore 2.1.5 app that's running in an Azure App Service instance:

HTTP Error 500.53 - URL Rewrite Module Error. Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip").

Symptoms include:

  1. Incomplete HTML responses (A 200 status code is returned, but occasionally only a portion of the content is displayed - refreshing the page 1-3 times usually fixes this)
  2. Frequently slow response times ~10-40 sec - it's as if the app isn't warmed up.

Possibly Relevant Information:

  • Application insights doesn't show any of these failures or slow response times anywhere.
  • I'm not explicitly using any rewrite rules in my config.
  • Calling/Not Calling app.UseResponseCompression() in startup doesn't make a difference
  • Calling/Not Calling app.UseHttpsRedirection() in startup doesn't make a difference
  • Enabling/Disabling "Https Only" in the azure portal doesn't make a difference
  • I'm not seeing any problems locally
  • Scaling between B1,B2,S1,S2 app service plans doesn't make a difference
  • Turning off https only and using non-ssl endpoints doesn't make a difference

Here's my WebHostBuilder call:

WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
    config.SetBasePath(Directory.GetCurrentDirectory());
})
.UseSerilog()
.UseStartup<Startup>()
.UseApplicationInsights();

The only similar results I find when Googling for this are 500.52 errors, but they're always related to incorrect url rewrite rules which I'm not (explicity) using.

1

1 Answers

2
votes

For others benefit, I recently hit on the same issue, after 2 hours deep diving into Azure portal, there seems a known issue with application insight with APPINSIGHTS_JAVASCRIPT_ENABLED setting enabled combined with <urlCompression ...> settings, you can find more details from the link below

https://github.com/Microsoft/ApplicationInsights-Home/issues/282

Two possible solutions

1. Turn off APPINSIGHTS_JAVASCRIPT_ENABLED

Set APPINSIGHTS_JAVASCRIPT_ENABLED to false either from your web.config appSetting or Azure App blade applicaiton setting


2. Turn off dynamicCompressionBeforeCache

Search in the web.config and Find <urlCompression ..> node, disable both static and dynamic compression <urlCompression doStaticCompression="false" doDynamicCompression="false" />.

If you have CDN like cloudflare configured, you should consider to remove urlCompression completely.