see*_*was 9 c# asp.net http2 iis-10
环境
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并且下载成功.
小智 0
在 HTTP2 中,如果文件名包含非 US-ASCII 字符,大多数浏览器将无法解析文件名。HTTP1.1 的实现对此更加宽松。
要仍然支持 utf-8 文件名,您可以使用带有 url 编码值的 filename* 属性。
目前最支持的 Content-Disposition 格式是:
attachment; filename="<us-ascii filename>"; filename*=utf-8''<url-encoded-utf-8-filename>
Run Code Online (Sandbox Code Playgroud)
IE。
attachment; filename="EURO rates"; filename*=utf-8''%e2%82%ac%20rates
Run Code Online (Sandbox Code Playgroud)