I want to allow users to display a pdf and save it on my asp.net project.
My code is below:
string yol = e.CommandArgument.ToString();
string path = Server.MapPath("~/Raporlar/2021/" + yol.Trim());
WebClient User = new WebClient();
Byte[] s = User.DownloadData(path);
System.IO.MemoryStream ms = new System.IO.MemoryStream(s);
if (ms != null && ms.Length > 1)
{
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Charset = "UTF-8";
Response.Buffer = true;
Response.AddHeader("Content-Length", ms.Length.ToString());
Response.AddHeader("Content-Disposition", "inline; filename="" + yol + """);
Response.AddHeader("Expires", "0");
Response.AddHeader("Pragma", "cache");
Response.AddHeader("Cache - Control", "private");
Response.ContentType = "application/pdf";
Response.BinaryWrite(ms.ToArray());
Response.Flush();
try { Response.End();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
catch { }
}
The display button only works Firefox. Other browsers (Google Chrome, Opera, Edge..) is not display the pdf and gives error like that:
Hmmm… This page is not available. The web page at https://massgrup.com/Raporlar.aspx may be experiencing some problems or has been permanently moved to a new web address.
ERR_HTTP2_PROTOCOL_ERROR
question from:
https://stackoverflow.com/questions/66053229/asp-net-display-pdf-on-chrome-error-err-http2-protocol-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…