URL Rewrite incompatibility

Found in

EPiServer.CMS.Core 11.15.1

Fixed in

EPiServer.CMS.Core 11.20.3


Sep 14, 2020


Jan 15, 2021


CMS Core


Closed, Fixed and tested


An error was discovered in a support case related to broken downloads of HTML-files: PAAS-11871

This bug happens for blob-downloads when they're sent to the client asynchronously and URL rewrite is configured to inject the Application Insights javascript.

It looks like it's related to Response.Flush called. When commenting out this line it starts working.
Similarly when adding a Response.Flush() call after the synchronous transmit-method that will also start failing, otherwise when it copies with stream.CopyTo() it'll read/write to the stream without a flush and that works as expected.

Steps to reproduce

  • Install URL rewrite (older version is installed by default, it needs version 2): https://www.iis.net/downloads/microsoft/url-rewrite
  • Enable rewrite-config: C:\Windows\System32\inetsrv>appcmd unlock config /section:allowedServerVariables
  • Setup IIS site for Alloy
  • Install EnvVarProvider dll: gacutil /i Microsoft.Web.Hosting.EnvVarProvider.dll
  • Setup environment variable: APPINSIGHTS_INSTRUMENTATIONKEY = d06bb9f2-1af0-428c-baed-a9626a5fbdf1
  • Setup environment variable: APPINSIGHTS_JAVASCRIPT_ENABLED = true
  • Set connection strings to use azure resources
  • Upload a .html file to media assets
  • Download the .html file from media assets

File is partially downloaded or browser reacts with a network-error.