Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

Asp.net Display Pdf on Chrome - Error ERR_HTTP2_PROTOCOL_ERROR

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I solved the problem. It is about ssl certifica.

When i click the button the link is like this : "https:https://massgrup.com/"

Because of that the button is not working on Chrome browsers.

After removing the ssl certificate the problem is resolved.

But now I will have to solve the problem of how to install the ssl certificate. This is a different situation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...