title: ASP.NET Core 1.0 custom compression middleware and static files issue
body: <p>My startup's middleware configuration looks something like this:</p>
  
  <pre><code>public void Configure(IApplicationBuilder app)
  {
      app.UseCompression();
      app.UseIISPlatformHandler();
      app.UseApplicationInsightsRequestTelemetry();
      app.UseCors("CorsPolicy");
      app.UseStaticFiles();
      app.UseMvc();
      app.UseApplicationInsightsExceptionTelemetry();
  }
  </code></pre>
  
  <p>Since adding the <code>app.UseCompression()</code> middleware, static html files in <code>wwwroot</code> aren't loading correctly anymore. <strong>They don't resolve and tend to load indefinitely.</strong></p>
  
  <p>The compression middleware looks as follows and was sourced from <a href="http://www.codeproject.com/Articles/1042980/Enabling-GZip-Compression-in-ASP-NET" rel="nofollow">here</a>:</p>
  
  <pre><code>public class CompressionMiddleware
  {
      private readonly RequestDelegate nextDelegate;
  
      public CompressionMiddleware(RequestDelegate next)
      {
          nextDelegate = next;
      }
  
      public async Task Invoke(HttpContext httpContext)
      {
          var acceptEncoding = httpContext.Request.Headers["Accept-Encoding"];
          //Checking that we have been given the correct header before moving forward
          if (!(String.IsNullOrEmpty(acceptEncoding)))
          {
              //Checking that it is gzip
              if (acceptEncoding.ToString().IndexOf("gzip", StringComparison.CurrentCultureIgnoreCase) &gt;= 0)
              {
                  using (var memoryStream = new MemoryStream())
                  {
                      var stream = httpContext.Response.Body;
                      httpContext.Response.Body = memoryStream;
                      await nextDelegate(httpContext);
                      using (var compressedStream = new GZipStream(stream, CompressionLevel.Optimal))
                      {
                          httpContext.Response.Headers.Add("Content-Encoding", new string[] { "gzip" });
                          memoryStream.Seek(0, SeekOrigin.Begin);
                          await memoryStream.CopyToAsync(compressedStream);
                      }
                  }
              }
              else
              {
                  await nextDelegate(httpContext);
              }
          }
          //If we have are given to Accept Encoding header or it is blank
          else
          {
              await nextDelegate(httpContext);
          }
  
      }
  }
  </code></pre>
  
  <p>Does anyone know why this could be happening?</p>
  
  <p>Note: I am using DNX <code>1.0.0-rc1-update1</code> and the <code>1.0.0-rc1-final</code> libraries.</p>