环境
Web.Config中:
<modules runAllManagedModulesForAllRequests="true">
<remove name="FormsAuthentication" />
</modules>
按钮点击:
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; }
}
问题: 在第一篇文章中,浏览器使用HTTP2作为其协议,下载失败。 Chrome网站&#34; 网络错误 - 无法下载&#34;
再次单击相同的链接,协议将回退到http / 1.1,下载成功。