小编see*_*was的帖子

C#Http2下载失败的网络错误

环境

  • ASP.NET网站
  • .NET 4.6.1
  • 在Windows Server 2016上的IIS 10.0中托管.

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并且下载成功.

  • 当前语法对于在HTTP2下传送文件有效吗?
  • 是否可以在IIS10/ASP.NET 4.6.1中强制使用http/1.1?

c# asp.net http2 iis-10

9
推荐指数
1
解决办法
685
查看次数

标签 统计

asp.net ×1

c# ×1

http2 ×1

iis-10 ×1