Solve HTTP2 Download Failed Network Error

Viewed 2095

Environment

  • ASP.NET website
  • .NET 4.6.1
  • Hosted in IIS 10.0 on Windows Server 2016.

Web.Config:

<modules runAllManagedModulesForAllRequests="true">
  <remove name="FormsAuthentication" />
</modules>

Button Click:

protected void btnDownload_Click(object sender, System.EventArgs e)
{
    try
    {
        string sPDFFilename = "doc.pdf";    
        byte[] data = GetData();            
        Response.ClearHeaders();
        Response.ClearContent();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "Attachment; filename=" + sPDFFilename);
        Response.AddHeader("content-length", (data.Length.ToString()));
        Response.BinaryWrite(data);
        Response.Flush();
        HttpContext.Current.ApplicationInstance.CompleteRequest();
    }
    catch(Exception ex){ throw; }
}

Question: On the first post back the browser use's HTTP2 for its protocol and the download fails. Chrome sites "Network Error - Failed to Download"

Click the same link again and the protocol falls back to http/1.1 and the download is successful.

  • Is the current syntax valid for delivering a file under HTTP2?
  • Is it possible to force http/1.1 in IIS10/ASP.NET 4.6.1?
0 Answers
Related