title: ERR_SPDY_PROTOCOL_ERROR when returning file from ASP.NET action
body: <p>I have some old Web API action method which returns CSV file. It worked for long time, but recently stopped. Now it causes ERR_SPDY_PROTOCOL_ERROR.</p>
  
  <p>ERR_SPDY_PROTOCOL_ERROR in Chrome is often associated with Avast security as described <a href="https://productforums.google.com/forum/#!topic/chrome/sfAqeo4hDy8" rel="nofollow noreferrer">here</a>. In my case however it's not caused by Avast, and other web browsers throw exceptions too.</p>
  
  <p>My action method looks as follows:</p>
  
  <pre><code>[HttpGet]
  [Route("csv")]
  public HttpResponseMessage SomeMethod([FromUri]SomeSearchCriteria sc)
  {
      using (MemoryStream stream = new MemoryStream())
      {
          StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
          string content = someLogic.SomeSearchmethod(sc);
          writer.Write(content);
          writer.Flush();
          stream.Position = 0;
  
          HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
          result.Content = new StreamContent(stream);
          result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/csv");
          result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "Export.csv" };
          return result;
      }              
  }
  </code></pre>
  
  <p>The method is called by angular front end by simple change of <code>window.location</code> on button click.</p>
  
  <p>Whole action method is executed properly, with no exceptions. Error is shown only by web browser.</p>
  
  <p>Flushing sockets in Chrome as described <a href="https://stackoverflow.com/questions/33867014/what-mean-err-spdy-protocol-error-in-nginx">here</a> does not solve the issue.</p>