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